home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / misc / 27319 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.9 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!TOROLAB6.VNET.IBM.COM!LANSCHE
  2. From: LANSCHE@TOROLAB6.VNET.IBM.COM ("Martin Lansche")
  3. Newsgroups: comp.os.os2.misc
  4. Subject: RE: Stem Variables as Arguments
  5. Message-ID: <9208131845.AA12317@ucbvax.Berkeley.EDU>
  6. Date: 13 Aug 92 17:09:24 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 57
  9.  
  10. Michael, Jean-Pierre,
  11.   A long time ago I suffered through the same dilemma.  There used to be
  12. a very ugly way to do this via
  13.  
  14. myfunc: Interpret "PROCEDURE EXPOSE" arg()
  15.  
  16. which violated the REXX language definition, but worked until about 1989
  17. - they enforced the language definition in the CMS version of REXX then.
  18. So I was able to get around it using a more elegant trick.  The central
  19. idea is that all of the stem variables that you could possibly want to
  20. use as an arguement to functions should be placed in a "SUPER-STEM".
  21.   For instance, instead of having
  22.     Opts.1 = "A"
  23.     Opts.2 = "B"
  24.     &c.
  25. code it instead as
  26.     Stem.Opts.1 = "A"
  27.     Stem.Opts.2 = "B"
  28. Then your can use PROCEDURE EXPOSE STEM., and pass as an argument the
  29. 1st level of indirection which, in essence, is your passed Stem variable.
  30. Here is Michael's sample rewritten with this technique.  Run with
  31. "Trace i" to see it at work.
  32.  
  33. Cheers,
  34. Martin Lansche   Lansche@Torolab6.vnet.ibm.com
  35.  
  36. =========== cut here =============
  37. /* Init the stem var. */
  38. Stem. = ''
  39. Stem.Opts.Label = 'Select an option A-C, X'
  40. Stem.Opts.0 = 4 /* No. options */
  41. Stem.Opts.1 = 'A'
  42. Stem.Opts.2 = 'B'
  43. Stem.Opts.3 = 'C'
  44. Stem.Opts.4 = 'X'
  45.  
  46. Choice = GetChoice("Opts")
  47. exit
  48. /* ... */
  49.  
  50. GetChoice: PROCEDURE EXPOSE STEM.
  51. ARG name  /* Stem var with options */
  52.  
  53. SAY Stem.name.Label
  54. PULL Resp
  55. DO i = 1 TO Stem.name.0
  56.    IF Resp = Stem.name.i THEN
  57.        LEAVE
  58. END /* i */
  59.  
  60. IF i = Stem.name.0 + 1 THEN /* Default is Stem.1 */
  61.    RETURN Stem.name.1
  62.  
  63. RETURN Stem.name.i
  64.  
  65. /* End of example */
  66.  
  67.