home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!Sirius.dfn.de!zam103!ibt013!kiehl
- From: kiehl@ibt013.ibt.kfa-juelich.de (Horst Kiehl)
- Newsgroups: comp.lang.rexx
- Subject: Re: Reading inline "code" as input?
- Keywords: inline, sourceline
- Message-ID: <275@zam103.zam.kfa-juelich.de>
- Date: 9 Sep 92 09:25:07 GMT
- References: <1992Sep8.163642.16833@midway.uchicago.edu>
- Sender: news@zam103.zam.kfa-juelich.de
- Reply-To: kiehl@ibt013.ibt.kfa-juelich.de (Horst Kiehl)
- Organization: Forschungszentrum Juelich GmbH (KFA), Germany
- Lines: 80
- Nntp-Posting-Host: ibt013
-
- In article <1992Sep8.163642.16833@midway.uchicago.edu>,
- sip1@ellis.uchicago.edu (Timothy F. Sipples) writes:
-
- >Is there any way a REXX program can take data input from itself
- >(without resorting to QUEUE or PUSH)?
-
- >I know I can detect how many lines are in the program -- there's a
- >function to do that -- but can I actually read the lines in?
-
- >The reason I am asking is that I am working on enhancements to
- >REXXShip, and a nice one would be to incorporate XXEncode
- >compatibility, which would mean having an unmodified stretch of bytes
- >in the middle of the code for purposes of encoding a binary file. The
- >REXX "wrapper" would read that stretch of bytes and decode the file.
-
- OK, so it's time to give help in the other direction...
-
- From "The REXX Language" (1985 edition though),
- Chapter 8, "Built-in Functions":
-
- SOURCELINE([n])
-
- If n is ommitted, returns the line number of the final line in the program.
-
- If n is given, the nth line in the program is returned. n must be a positive whole
- number, and must not exceed the numbr of the final line in the program.
-
- So you could insert the XXEncoded stuff in a comment in the middle
- of the program, like:
-
- /* XX:
- SDFJKGSASD
- ASDFJASDLD
- ASDFLASDFL
- ASDFL
- */
-
- and locate the line containing ' XX:' by a loop using SOURCELINE.
-
- But it is "cleaner" to use an internal subroutine call instead of SIGNAL
- (which is for exception purposes only), like:
-
- /* REXXShip */
-
- call decode_contents
-
- exit
-
- /* XX:
- SDFJKGSASD
- ASDFJASDLD
- ASDFLASDFL
- ASDFL
- */
-
- decode_contents:
-
- do i= 1 to sourceline() until pos(' XX:', sourceline(i)) \== 0
- end
-
- /* Here, I's value is either the number of the first line with XX-code */
- /* or greater than SOURCELINE() */
-
- if i >> sourceline() then
-
- say 'Error'
-
- else do
-
- /* Decode */
-
- end
-
- return
-
- I hope (well, I'm quite sure) :-) this helps.
-
- All the best,
-
- Horst
-