"RLMuller" <RLMuller / comcast.net> wrote > <snip> > > The Windows API has a function for opening an input > dialog that accepts a string which gets returned to > the caller. And Win32API provides a way to get to such a > function. > > > From: "Hal E. Fulton" <hal9000 / hypermetrics.com> > <snip> > > > > Maybe a simple GUI would help that. It should only > > take a few lines in the GUI of your choice to > > throw up a dialog box... of course, to get a little > > fancier, you could use some specialized widget that > > browses for filenames in a tree. > > > > If you do something like that, why don't you share > > it with the list? > > Swin gives easy access to some Win32 dialogs (and more) and is included in /\ndy's PragProg distro. (Part of VisualuRuby on RAA) English documention is 'swin.c' ;-) ###---<code> require 'swin' # OFN_ from 'commdlg.h' OFN_HIDEREADONLY = 0x0004 OFN_PATHMUSTEXIST = 0x0800 OFN_FILEMUSTEXIST = 0x1000 # Starting directory (uses current 'default', otherwise) # Dir.chdir('D:\ruby') # make your own array of file filters filter = [ ["Text files","*.txt"], ["All files","*.*"] ] #filename = 'readme.txt' # bypass OpenDialog filename ||= SWin::CommonDialog::openFilename(nil, filter, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST, 'Select File', # Box Title 'txt') # default extension if !filename puts 'Open cancelled' # exit(1) end puts filename #filename = SWin::CommonDialog::saveFilename(nil, filter) #puts filename ###---</code> It saves much cutting/pasting/typing of filenames to put this in simple non-GUI scripts instead of using a filename argument. daz