home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / rexx / 741 < prev    next >
Encoding:
Text File  |  1992-08-19  |  2.9 KB  |  80 lines

  1. Newsgroups: comp.lang.rexx
  2. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!ugle!anders
  3. From: anders@lise11.lise.unit.no (Anders Christensen)
  4. Subject: Re: Capturing System Command Output (was: SH Backquote)
  5. In-Reply-To: jpr@hp10.lri.fr's message of 19 Aug 92 13:54:45 GMT
  6. Message-ID: <ANDERS.92Aug19215104@lise11.lise.unit.no>
  7. Sender: news@ugle.unit.no (NetNews Administrator)
  8. Organization: /home/flipper/anders/.organization
  9. References: <19920818081215SEB1525@MVS.draper.com> <1992Aug19.155445@hp10.lri.fr>
  10. Date: 19 Aug 92 21:51:04
  11. Lines: 67
  12.  
  13. In article <1992Aug19.155445@hp10.lri.fr> jpr@hp10.lri.fr (Jean-Pierre Riviere) writes:
  14.  
  15. > Well, I am not a specialist but whatthe hell is the "RESULT" var done for ?
  16.  
  17. The special variable RESULT is set at the return from a subroutine
  18. called by a CALL clause, when the called routine returned a result, in
  19. order to catch a value that would otherwise be lost.
  20.  
  21. To call a program and get the RESULT variable set on return, and still
  22. be within TRL, do the following:
  23.  
  24.    call 'ls' "-l ~"
  25.    dir = result
  26.  
  27. Note the difference between calling an external function, and issuing
  28. a command, that is two conceptually very different methods.
  29.  
  30. Unfortunately, it is not clearly specified in TRL _what_ to interpret
  31. as the 'result' from an external function if it is not a rexx
  32. function. Is it the output (the characters written to standard
  33. output); or is it the return value (the expression given to statements
  34. like exit and return?)
  35.  
  36. > Would not be the better way be
  37. >
  38. > "ls -l ~"
  39. > dir = result
  40.  
  41. Perhaps, but if the program has more complex output, like the
  42. 'directory/full' under vms, you're stuck with one mega RESULT string,
  43. and have to do some moby parsing to get the various fields. Putting
  44. the result from a command into a single variable _only_ works (in a
  45. practical sense) if the output is either small or well structured.
  46.  
  47. As a concequence, there most a another method (either instead of or in
  48. addition to the result-method), that handles complexly structured
  49. output from commands. The solution _might_ be to use compound
  50. variables in stead of simple variables (i.e. result.1, result.2 ....
  51. etc, instead of just result). But I don't think that the only Correct
  52. Answer either.
  53.  
  54. > (This is the only available way to do it with arexx btw)
  55. > It's common rexx anf follows Cowlishaw's rules. (as far as I 
  56. > understood it...)
  57.  
  58. IMHO this is not TRL, and IMNSHO arexx is not TRL.
  59.  
  60. > So why are you trying to implement hassles with
  61. > dir = "ls -l ~"
  62. >
  63. > and all its derivative ?
  64.  
  65. The statement that you think of is probably something like
  66.  
  67.     dir = "ls"( "-l ~" )
  68.  
  69. Which is calling the program 'ls' with the parameter(s) '-l ~' and
  70. assigning the 'outdata' (whether it be the return code or standard
  71. output) to the variable 'dir'. That _is_ within TRL, although it does
  72. not require it.
  73.  
  74. > Cannot the result way be good enough for us ?
  75.  
  76. As a solution, yes. As the only solution, no.
  77.  
  78. -anders
  79.