/* * Rexx tool to open a drawer on the WB * Supply noreq argument at end to prevent requestor: * Usage: openwb dir [noreq] * $VER: Openwb 2.1 * Original by Dave Trollope * 24/05/00 modified with input from Philippe 'Elwood' Ferrucci * 28/05/00 modified with input from the OS3.5 Mailing List * 14/07/00 modified to handle relative paths * Without the help of Jörg Strohmayer * and Robert A. Sisk filenames with spaces * wouldn't work. */ result=0 options results parse arg opts /* Parse out the args, spaces screw up the arg list, so * count the words, the last one will be noreq if its there. * All other args are the directory name. */ w=words(opts) opt="" if w == 0 then dir="" else do if word(opts,w) == "noreq" then do if w > 1 then dir=substr(opts,1,wordindex(opts,w) - 2) else dir="" opt="noreq" end else dir=opts end qdir = '"'||dir||'"' /* Get the current dir */ curdir = ""PRAGMA(D) qcurdir = '"'curdir'"' /* Assume the wb window will be opened unless an error occurs */ openwbwin = 1 /* Was the noreq option given? as the second arg? */ if (opt == "") then do /* Address AmigaDOS */ address command /* Request the drawer to open, if no drawer given, use current dir */ if (dir == '') | (dir == '""') then requestfile drawersonly qcurdir title '"Pick drawer to open on WB"' ">T:openwb" else requestfile drawersonly qdir title '"Pick drawer to open on WB"' ">T:openwb" /* Check return code of requestfile for cancel button */ if rc == 5 then openwbwin = 0 /* Cancelled, don't bother */ else do address /* Open the file with the drawer name selected */ if open('tempd','t:openwb',read) == 1 then do dir = readln('tempd') dir = strip(dir,b,'"') qdir = '"'||dir||'"' close('tempd') end end end /* If no error occurred, open the window */ if openwbwin == 1 then do if (dir == '') | (dir == '""') then do dir = curdir qdir = qcurdir end if index(dir,':') == 0 then do /* Is curdir the root directory? */ if index(curdir,':') == length(curdir) then delim = "" else delim = "/" tdir = curdir||delim||dir say D tdir if exists(tdir) == 1 then do /* This is a relative path, add current dir */ dir = tdir qdir = '"'||tdir||'"' end end address workbench if exists(dir) then interpret window "' " || qdir || " '" open else say d2c(7)||"Can't find "||dir||" - directory doesn't exist". end .