Xref: utzoo comp.lang.rexx:352 comp.sys.amiga.tech:16222 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!van-bc! From: lphillips@lpami.wimsey.bc.ca (Larry Phillips) Newsgroups: comp.lang.rexx,comp.sys.amiga.tech Subject: Re: Follow the true Way -- A PLEA!! for good program design. Keywords: AREXX , * Message-ID: <2239@lpami.wimsey.bc.ca> Date: 17 Nov 90 18:58:36 GMT Lines: 52 Return-Path: To: van-bc!rnews In <1990Nov17.080652.28036@watcsc.waterloo.edu>, psop@watcsc.waterloo.edu (Paul Sop) writes: >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. That's fine for some things I suppose, but breaks other things. I have a little ARexx program I call 'hilite', that lets me see text patterns in an alternate colour. I typically use it in a pipe, so that I can see the context of the output, which is a lot better at times than using grep and getting only single lines out. Here's the program... /* hilite.rexx - hilite a substring usage is from stdin, with pipe. hilites the argument string */ parse arg x do forever parse pull ln if EOF(stdin) then exit if pos(translate(x),translate(ln)) = 0 then say ln else do call writech(stdout,substr(ln,1,pos(translate(x),translate(ln))-1)) call writech(stdout,'1b'x || '[33m' || x || '1b'x || '[31m') call writech(stdout,substr(ln,pos(translate(x),translate(ln))+ length(x)) || '0a'x) end end An example of calling it... dir all | hilite foo Using your open/close stdin line breaks it. Other than the special cases, though. it's a good idea. -larry -- The only things to survive a nuclear war will be cockroaches and IBM PCs. +-----------------------------------------------------------------------+ | // Larry Phillips | | \X/ lphillips@lpami.wimsey.bc.ca -or- uunet!van-bc!lpami!lphillips | | COMPUSERVE: 76703,4322 -or- 76703.4322@compuserve.com | +-----------------------------------------------------------------------+