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

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!CESTRIAN.CCF.SWRI.EDU!CHRIS
  3. Return-Path: <chris@cestrian.ccf.swri.edu>
  4. Message-ID: <9208131418.AA0245@cestrian.ccf.swri.edu>
  5. Newsgroups: comp.lang.rexx
  6. Date:         Thu, 13 Aug 1992 08:09:12 EST
  7. Sender:       REXX Programming discussion list <REXXLIST@UGA.BITNET>
  8. From:         chris@CESTRIAN.CCF.SWRI.EDU
  9. Subject:      Re: Stem vars as arguments?
  10. Comments: To: REXXLIST@OHSTVMA.ACS.OHIO-STATE.EDU
  11. Lines: 63
  12.  
  13. Dave,
  14.   You would have won the bet. I had tested small pieces on the mainframe
  15.    (VM/XA) and then just edited the sample in the note I was replying to.
  16.  
  17.   There were two major bluders in my example:
  18.      1. The PROCEDURE instruction, by default, hides all variables thus
  19.           making access to the stem impossible.
  20.  
  21.      2. The VM function FIND has been renamed to WORDPOS in OS/2. The
  22.            help for both OS's is almost word for word.
  23.  
  24.   Here is a working example.
  25.  
  26.  
  27. /* */
  28. Opts.Label = 'Select an option A-C, X'
  29. Opts.0 = 4 /* No. options */
  30. Opts.1 = 'A'
  31. Opts.2 = 'B'
  32. Opts.3 = 'C'
  33. Opts.4 = 'X'
  34.  
  35. Choice = GetChoice(Opts)
  36. say choice
  37. choice=getopts('Select options A-C or X $ A B C X')
  38. say choice
  39. exit
  40. /* ... */
  41.  
  42. GetChoice:
  43.    ARG Stem
  44.    interpret 'lab='stem'.label'         /* Get value of stem.label */
  45.    SAY lab                              /* Use it for prompt */
  46.    PULL Resp
  47.    interpret 'range='stem'.0'           /* Get value of stem.0 */
  48.    do  i = 1 TO range
  49.           interpret 'choice='stem'.'i   /* Get stem value */
  50.           IF Resp = choice  THEN        /* This it ? */
  51.                   LEAVE
  52.    END
  53.    if resp<>choice then i = 1           /* Didn't match chose first  */
  54.    interpret 'ret='stem'.'i             /* Get the choice */
  55. RETURN ret
  56.  
  57. /*
  58. Note that the above method will only work with internal procedures.
  59. For the example as stated I would use something like this
  60. */
  61.  
  62. getopts:
  63.    parse arg label '$' choices
  64.    say label
  65.    pull choice
  66.    if 0=wordpos(choice,choices) then choice=word(choices,1)
  67. return choice
  68.  
  69. /* End of example */
  70.  
  71. Sorry for the confusion. Guess I'll go wash the egg off my face now.
  72.  
  73. Wizardy is Wonderful
  74.  
  75. Later .....
  76.