home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!pacbell.com!charon.amdahl.com!amdahl!JUTS!NewZealand!chappy
- From: chappy@duts.ccc.amdahl.com (Chappy Cole)
- Newsgroups: comp.lang.rexx
- Subject: Re: Stem vars as arguments?
- Message-ID: <d7c802aM1dOP01@JUTS.ccc.amdahl.com>
- Date: 13 Aug 92 16:48:23 GMT
- References: <ednstras.713591629@kraken>
- Sender: netnews@ccc.amdahl.com
- Reply-To: chappy@duts.ccc.amdahl.com
- Organization: Happy hacker bait and tackle shop
- Lines: 108
-
- I don't believe that anyone answered your question about how you might accomplish your
- goals on VM/Rexx. Under CMS8, PIPELINES is a part of CMS; therefore, you could use
- PIPELINES. PIPELINES has multiple 'device drivers' that use the EXECCOMM interface to
- access Rexx variables. These drivers can be used to look up variables from variable
- pools for active execs that are predecessors to the exec using PIPELINES.
-
- For your particular problem of assigning some values to a stem that can be specified
- by the calling program you could code the following:
-
- /* Top level exec which calls another to set the stem 'Opts.' */
- 'EXEC STEMFILL OPTS.' /* Pass stem name as argument */
- do i = 1 to Opts.0
- say 'Opts.'i '=' Opts.i
- end i
- exit
-
- /* STEMFILL EXEC - Assigns hardcoded values to the passed stem in the calling exec */
- parse upper arg Stem .
- Mystem.0 = 4
- Mystem.1 = 'A'
- Mystem.2 = 'B'
- Mystem.3 = 'Z'
- Mystem.4 = 'Y'
- 'PIPE stem Mystem.' , /* Put 'Mystem.' values into pipeline */
- '| stem' Stem '1' /* Put stream values into callers 'stem' */
- exit rc
-
- That is one way to solve your problem on VM/CMS with PIPELINES. However, it sounds to
- me like you are not using VM. I am not exactly sure of what you want to do, so I will
- continue based on my understanding.
-
- If you are unable to use a tool, like PIPELINES, to allow an external routine to create
- variables in the calling exec, then you will have to solve the problem in your exec.
- If your goal is to pass the name of the stem which already contains the data to be
- referenced, then I suggest the following:
-
- /* */
- Opts.0 = 3
- Opts.1 = 'TERM'
- Opts.2 = 'PROFILE'
- Opts.3 = 'MYPROF'
- call DisplayStem 'Opts.'
- exit
-
- DisplayStem: /* Note: you cannot use 'procedure' */
-
- arg Stem .
- do i = 1 to value(Stem'0')
- say 'The value of' Stem''i 'is:' value(Stem''i)
- end i
-
- return
-
- Note that I used the 'value' function to get at the values of the passed stem. I feel
- that this is much easier to code and to read than using the 'interpret' instruction.
- However, if you want to pass the name of the stem to be assigned some values, then you
- must use 'interpret'. The reason is that the 'value' function can only lookup the
- value of a variable - it cannot execute any instructions. To assign a value, you must
- execute "variable = value". To pass the name of the stem to be assigned, try something
- like this:
-
- /* */
- call SetOpts 'Opts.'
- /* rest of code here */
- exit
-
- SetOpts: /* Again, you cannot use 'procedure' */
-
- arg Stem
-
- interpret Stem'0 = 3' /* Turns into 'Opts.0 = 3' */
- interpret Stem'1 = "TERM"' /* Turns into 'Opts.1 = "TERM"' */
- interpret Stem'2 = "PROFILE"' /* Turns into 'Opts.2 = "PROFILE"' */
- interpret Stem'3 = "MYPROF"' /* Turns into 'Opts.3 = "MYPROF"' */
-
- return
-
-
- Note that you cannot use the 'procedure' instruction in either case because the stem
- that is being referenced in both cases is unknown at the time the subroutine is
- created. One person detailed a feature of Rexx 4.0 which allows you to 'procedure
- expose (var)', such that 'var' is interpreted before the 'procedure expose' is. If you
- have Rexx 4.0, then you should be able to code the following:
-
- /* */
- Stem = 'Opts.'
- Opts.0 = 3
- Opts.1 = 'TERM'
- Opts.2 = 'PROFILE'
- Opts.3 = 'MYPROF'
- call DisplayStem
- exit
-
- DisplayStem: procedure expose (Stem) Stem
-
- do i = 1 to value(Stem'0')
- say 'The value of' Stem''i 'is:' value(Stem''i)
- end i
-
- return
-
-
- Note that the only thing you gain from this, is that you are only exposing the stem
- that you intend to, not all other variables in the program.
-
- I hope this helps. If you need more assistance, feel free to respond to me directly.
-
- Chappy
-