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

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!pacbell.com!charon.amdahl.com!amdahl!JUTS!NewZealand!chappy
  2. From: chappy@duts.ccc.amdahl.com (Chappy Cole)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Stem vars as arguments?
  5. Message-ID: <d7c802aM1dOP01@JUTS.ccc.amdahl.com>
  6. Date: 13 Aug 92 16:48:23 GMT
  7. References: <ednstras.713591629@kraken>
  8. Sender: netnews@ccc.amdahl.com
  9. Reply-To: chappy@duts.ccc.amdahl.com
  10. Organization: Happy hacker bait and tackle shop
  11. Lines: 108
  12.  
  13. I don't believe that anyone answered your question about how you might accomplish your
  14. goals on VM/Rexx.  Under CMS8, PIPELINES is a part of CMS; therefore, you could use
  15. PIPELINES.  PIPELINES has multiple 'device drivers' that use the EXECCOMM interface to
  16. access Rexx variables.  These drivers can be used to look up variables from variable
  17. pools for active execs that are predecessors to the exec using PIPELINES.  
  18.  
  19. For your particular problem of assigning some values to a stem that can be specified
  20. by the calling program you could code the following:
  21.  
  22. /* Top level exec which calls another to set the stem 'Opts.' */
  23. 'EXEC STEMFILL OPTS.' /* Pass stem name as argument */
  24. do i = 1 to Opts.0
  25.   say 'Opts.'i '=' Opts.i
  26. end i
  27. exit
  28.  
  29. /* STEMFILL EXEC - Assigns hardcoded values to the passed stem in the calling exec */
  30. parse upper arg Stem .
  31. Mystem.0 = 4
  32. Mystem.1 = 'A'
  33. Mystem.2 = 'B'
  34. Mystem.3 = 'Z'
  35. Mystem.4 = 'Y'
  36. 'PIPE stem Mystem.' ,   /* Put 'Mystem.' values into pipeline */
  37.   '| stem' Stem '1'     /* Put stream values into callers 'stem' */
  38. exit rc
  39.  
  40. That is one way to solve your problem on VM/CMS with PIPELINES.  However, it sounds to
  41. me like you are not using VM.  I am not exactly sure of what you want to do, so I will
  42. continue based on my understanding.
  43.  
  44. If you are unable to use a tool, like PIPELINES, to allow an external routine to create
  45. variables in the calling exec, then you will have to solve the problem in your exec.  
  46. If your goal is to pass the name of the stem which already contains the data to be
  47. referenced, then I suggest the following:
  48.  
  49. /* */
  50. Opts.0 = 3
  51. Opts.1 = 'TERM'
  52. Opts.2 = 'PROFILE'
  53. Opts.3 = 'MYPROF'
  54. call DisplayStem 'Opts.'
  55. exit
  56.  
  57. DisplayStem: /* Note: you cannot use 'procedure' */
  58.  
  59.   arg Stem .
  60.   do i = 1 to value(Stem'0')
  61.     say 'The value of' Stem''i 'is:' value(Stem''i)
  62.   end i
  63.  
  64. return
  65.  
  66. Note that I used the 'value' function to get at the values of the passed stem.  I feel
  67. that this is much easier to code and to read than using the 'interpret' instruction.
  68. However, if you want to pass the name of the stem to be assigned some values, then you
  69. must use 'interpret'.  The reason is that the 'value' function can only lookup the
  70. value of a variable - it cannot execute any instructions.  To assign a value, you must
  71. execute "variable = value".  To pass the name of the stem to be assigned, try something
  72. like this:
  73.  
  74. /* */
  75. call SetOpts 'Opts.'
  76. /* rest of code here */
  77. exit
  78.  
  79. SetOpts: /* Again, you cannot use 'procedure' */
  80.  
  81.   arg Stem
  82.  
  83.   interpret Stem'0 = 3'           /* Turns into 'Opts.0 = 3'         */
  84.   interpret Stem'1 = "TERM"'      /* Turns into 'Opts.1 = "TERM"'    */
  85.   interpret Stem'2 = "PROFILE"'   /* Turns into 'Opts.2 = "PROFILE"' */
  86.   interpret Stem'3 = "MYPROF"'    /* Turns into 'Opts.3 = "MYPROF"'  */
  87.  
  88. return
  89.  
  90.  
  91. Note that you cannot use the 'procedure' instruction in either case because the stem
  92. that is being referenced in both cases is unknown at the time the subroutine is 
  93. created.  One person detailed a feature of Rexx 4.0 which allows you to 'procedure 
  94. expose (var)', such that 'var' is interpreted before the 'procedure expose' is.  If you
  95. have Rexx 4.0, then you should be able to code the following:
  96.  
  97. /* */
  98. Stem = 'Opts.'
  99. Opts.0 = 3
  100. Opts.1 = 'TERM'
  101. Opts.2 = 'PROFILE'
  102. Opts.3 = 'MYPROF'
  103. call DisplayStem
  104. exit
  105.  
  106. DisplayStem: procedure expose (Stem) Stem
  107.  
  108.   do i = 1 to value(Stem'0')
  109.     say 'The value of' Stem''i 'is:' value(Stem''i)
  110.   end i
  111.  
  112. return
  113.  
  114.  
  115. Note that the only thing you gain from this, is that you are only exposing the stem
  116. that you intend to, not all other variables in the program.  
  117.  
  118. I hope this helps.  If you need more assistance, feel free to respond to me directly.
  119.  
  120. Chappy
  121.