At 13:50 -0400 2006/08/24, Miller, Raul D wrote:
Joey K Tuttle wrote:iMg5:~ jkt$ cat /usr/local/bin/jfactor #!/usr/local/lib/j601/jconsole 3 : 0 ARGV stdout NL,~": q: ". >2{y exit 0 )On my system, NL gives me a value error, perhaps you meant LF? Also, personally I prefer to use echo rather than stdout LF,~": (echo is simpler and seems more robust in the context of array arguments). And, of course, other stylistic differences are possible. I'd be tempted to write the above script as: #!/usr/local/lib/j601/jconsole 3 :'echo q: 0 ".>y' 2}.ARGV exit 0 Or, if I wanted errors to be indicated using a return code, and wanted a more "featureful" routine, I might instead do: #!/usr/local/lib/j601/jconsole 9!:29]1[9!:27 'exit 1 [ echo 13!:12>a:' echo q: ".;:inv 2}.ARGV exit 0 (The first line provides an error message and an exit code on hitting an error, and I changed the second line to allow the use of arbitrary J expressions rather than just numbers.) (Of course other variations are possible...)
I agree with your points. I use NL in my (modified) profile.ijs so that verbs using it can provide appropriate NewLines - normally it is set to LF (as I use Linux/Darwin) but sometimes it gets set to <CR><LF> for saving DOS files. Sorry that I was sloppy in using my own environment... Your first script is indeed prettier. I like the error exit code control in your second example - thanks for the ideas. - joey ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
