Xref: utzoo comp.lang.rexx:350 comp.sys.amiga.tech:16165 Newsgroups: comp.lang.rexx,comp.sys.amiga.tech Path: utzoo!utgpu!watserv1!maytag!watcsc!psop From: psop@watcsc.waterloo.edu (Paul Sop) Subject: Follow the true Way -- A PLEA!! for good program design. Message-ID: <1990Nov17.080652.28036@watcsc.waterloo.edu> Keywords: AREXX , * Reply-To: psop@watcsc.waterloo.edu (Paul Sop) Organization: University of Waterloo Computer Science Club Date: Sat, 17 Nov 90 08:06:52 GMT I want everyone, from now on, everywhere, who owns an amiga, to, when they write AREXX programs (note! I didn't say 'Scripts'), include the following **EXTREMELY IMPORTANT** line: call close 'STDIN';call open 'STDIN','*','R' NOTE the '*'. If more amiga programs used this method of reading input, life would be considerably better, easier, and all round more fun. Why? You query? Well... To illustrate what happens when you LEAVE the magic line out of an AREXX program, consider the following itty bitty AREXX program: /* a wonderful illustration of what happens when you leave it out.rexx */ options prompt 'A wonderful prompt> ' do forever pull null say null end exit 1 Ok now... You can Rx out.rexx and it works just like you expect.. but what if you: Run rx >con:0/0/640/400/Window Out.Rexx In this example, the program would just run forever, never able to get input from the user. It would just keep printing the prompt, and printing null strings (and boy is that one teriffic waste of CPU time let me tell you! :-) The same sort of thing happens when you run dir ? The template comes up, but you can't enter anything, and the program quits. This 'feature' can be devastating, as in the example: run format drive df0: name Uh-Oh which would wipe out whatever disk is in DF0: without prompting you. The line I expect you all to add from now on (re-iterated here:) call close 'STDIN';call open 'STDIN','*','R' Will ** FIX ** this. Now you'll be able to RUN programs in windows and be able to get output from them, AND send input TO them! That means, you can RUN programs, but still enter a few parameters before they leave and run in the background. You can now pipe output to console windows, AND TYPE INTO THEM TOO! And as soon as the program exits, it's window is automatically closed. Wonderful stuff. You all have (no doubt) noticed that if you did something dumb like: ADDRESS COMMAND "dir ?" from an AREXX program, the effect would be similar to running it, in that you wouldn't be able to interact with the directory command (a major pitfall!). If the DIR command opened it's file channel as '*' for input, IT WOULD WORK! In this way, you could transparently INVOKE INTERACTIVE CLI COMMANDS from AREXX programs! I will post some skelleton C code to let you do this. If you don't do your line-oriented I/O in this SIMPLE SIMPLE SIMPLE way, then your programs, and their integration with other system programs and standards, will SUFFER. A bonus of doing something like: run rx >con:0/0/640/400/Out Out.rexx /* The previous example */ is that when the program finished (by a ^C maybe?) then the window automatically closes. The only other way you can achieve this is by running it from (gag... dare we say) Workbench (where the window management provided by AREXX is slow as heck), or starting it from a newcli batchfile like this: rx out.rexx endcli (a script which is invoked like: newcli window con:0/0/640/400/Out from batchfile. ) Anyway.... Thank you for lending me your ears. I trust that you will realize the importance of writing programs this way, and that you will do it from now on and make everyone happy. Simulating psychedelic milieus with flashing lights and hallucinogenics: ............................................................................. z s w a m p . f i d o n e t . o r g ! l i l l i p u t ! u n i x 4 ! p s o p 4 - O R - p s o p @ w a t c s c . w a t e r l o o . e d u ............................................................................. Mail me if you're mean.