lphillips@lpami.wimsey.bc.ca (Larry Phillips) (05/17/89)
There are many advantages to adding a 'front-end' to a command. Alias is a good example of a simple front-end. You could, for example, use Alias to specify command line options that make the command act like you want it to, like this... Alias copy "copy [] clone" This will predefine the option 'clone' for you. If you now want to do a copy without the 'clone' option, you simply call it with the path specified, like: C:copy foo bar and the alias will be bypassed. ARexx provides a similar facility, but with much more power. You can, by writing an ARexx program of the same name as the one you want to change the behaviour of, analyze the arguments, the date/time, contents of a directory, contents of a file and more, before calling the actual program. A good example would be the FORMAT command. You could look for the presence of a hard drive name, and ask the user if he wants to go ahead. The same script might pass the command through unchanged if it's directed at a floppy. ------------------cut-------------- /* format.rexx */ arg x if index(x,'DH') then do say 'Are you sure you want to format this hard drive?' pull answer if left(anwser,1,1) = 'Y' then address command echo x else say 'Operation cancelled. Whew!' end else address command echo x ------------------cut-------------- This type of front end will woork best when run from WShell, since you will not have to remember to type 'rx' in front of the command. In the case of something as drastic as FORMAT, you might even want to change the name of FORMAT to something else, so that the the real FORMAT will not be called if you forget to type the 'rx'. Though the operations performed by the front-end are usually closely related to the command itself, there is no need for it to be that way. Here is a little script that I call every day, since I run aterm every day. It forces me to remember to update my weather log (I'm trying to correlate weather with tropical fish breeding activity), and even lets me update the weatherlog on the spot. If the weatherlog file has already been updated, or if it's before noon, the file remains untouched. If you don't have 'execio', you could redirect the output of the LIST to a temp file and read that in. ------------------cut-------------- /* aterm.rexx - get weather info, then run aterm */ 'C:list db:weatherlog | execio for 1 var fileinf' if pos('Today',fileinf) = 0 then if time() > '12:00:00' then do call writeln(stdout,'Weather today? ') x = readln(stdin) call open(log,'db:weatherlog','a') call writeln(log,date() x) end run aterm ------------------cut-------------- -larry -- - Don't tell me what kind of a day to have! - +----------------------------------------------------------------------+ | // Larry Phillips | | \X/ lphillips@lpami.wimsey.bc.ca or uunet!van-bc!lpami!lphillips | | COMPUSERVE: 76703,4322 | +----------------------------------------------------------------------+