home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / rexx / 959 < prev    next >
Encoding:
Text File  |  1992-09-08  |  2.5 KB  |  95 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!Sirius.dfn.de!zam103!ibt013!kiehl
  2. From: kiehl@ibt013.ibt.kfa-juelich.de (Horst Kiehl)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Reading inline "code" as input?
  5. Keywords: inline, sourceline
  6. Message-ID: <275@zam103.zam.kfa-juelich.de>
  7. Date: 9 Sep 92 09:25:07 GMT
  8. References: <1992Sep8.163642.16833@midway.uchicago.edu>
  9. Sender: news@zam103.zam.kfa-juelich.de
  10. Reply-To: kiehl@ibt013.ibt.kfa-juelich.de (Horst Kiehl)
  11. Organization: Forschungszentrum Juelich GmbH (KFA), Germany
  12. Lines: 80
  13. Nntp-Posting-Host: ibt013
  14.  
  15. In article <1992Sep8.163642.16833@midway.uchicago.edu>,
  16. sip1@ellis.uchicago.edu (Timothy F. Sipples) writes:
  17.  
  18. >Is there any way a REXX program can take data input from itself
  19. >(without resorting to QUEUE or PUSH)?
  20.  
  21. >I know I can detect how many lines are in the program -- there's a
  22. >function to do that -- but can I actually read the lines in?
  23.  
  24. >The reason I am asking is that I am working on enhancements to
  25. >REXXShip, and a nice one would be to incorporate XXEncode
  26. >compatibility, which would mean having an unmodified stretch of bytes
  27. >in the middle of the code for purposes of encoding a binary file.  The
  28. >REXX "wrapper" would read that stretch of bytes and decode the file.
  29.  
  30. OK, so it's time to give help in the other direction...
  31.  
  32. From "The REXX Language" (1985 edition though),
  33. Chapter 8, "Built-in Functions":
  34.  
  35.    SOURCELINE([n])
  36.  
  37.       If n is ommitted, returns the line number of the final line in the program.
  38.  
  39.       If n is given, the nth line in the program is returned. n must be a positive whole
  40.       number, and must not exceed the numbr of the final line in the program.
  41.  
  42. So you could insert the XXEncoded stuff in a comment in the middle
  43. of the program, like:
  44.  
  45.    /* XX:
  46.    SDFJKGSASD
  47.    ASDFJASDLD
  48.    ASDFLASDFL
  49.    ASDFL
  50.    */
  51.  
  52. and locate the line containing ' XX:' by a loop using SOURCELINE.
  53.  
  54. But it is "cleaner" to use an internal subroutine call instead of SIGNAL
  55. (which is for exception purposes only), like:
  56.  
  57.    /* REXXShip */
  58.  
  59.    call decode_contents
  60.  
  61.    exit
  62.  
  63.    /* XX:
  64.    SDFJKGSASD
  65.    ASDFJASDLD
  66.    ASDFLASDFL
  67.    ASDFL
  68.    */
  69.  
  70.    decode_contents:
  71.  
  72.       do i= 1 to sourceline() until pos(' XX:', sourceline(i)) \== 0
  73.       end
  74.  
  75.       /* Here, I's value is either the number of the first line with XX-code */
  76.       /*                    or greater than SOURCELINE()                     */
  77.  
  78.       if i >> sourceline() then
  79.  
  80.          say 'Error'
  81.  
  82.       else do
  83.  
  84.          /* Decode */
  85.  
  86.       end  
  87.  
  88.    return
  89.  
  90. I hope (well, I'm quite sure) :-) this helps.
  91.  
  92. All the best,
  93.  
  94. Horst
  95.