home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.rexx:707 comp.os.os2.misc:27301
- Path: sparky!uunet!mcsun!corton!lri!jpr
- From: jpr@sun4.lri.fr (Jean-Pierre Riviere)
- Newsgroups: comp.lang.rexx,comp.os.os2.misc
- Subject: Re: Stem vars as arguments?
- Message-ID: <1992Aug13.091449.11425@lri.fr>
- Date: 13 Aug 92 09:14:49 GMT
- References: <ednstras.713591629@kraken>
- Sender: jpr@sun4 (Jean-Pierre Riviere)
- Organization: Laboratoire de Recherche en Informatique
- Lines: 91
-
-
- In article <ednstras.713591629@kraken>, ednstras@kraken.itc.gu.edu.au
- (Michael Strasser) writes:
- |> I am writing a complicated REXX program under OS/2 2.0. I would like
- |> to be
- |> able to use a stem variable as an argument to an internal procedure,
- |> but my
- |> attempts have failed so far.
-
- I too have encountered similar problems of which I wanted to post today...
-
- |> Here is a simple example:
- |>
- |> /* Init the stem var. */
- |> Opts.Label = 'Select an option A-C, X'
- |> Opts.0 = 4 /* No. options */
- |> Opts.1 = 'A'
- |> Opts.2 = 'B'
- |> Opts.3 = 'C'
- |> Opts.4 = 'X'
- |>
- |> Choice = GetChoice(Opts)
- |>
- |> /* ... */
- |>
- |> GetChoice: PROCEDURE
- |> ARG Stem /* Stem var with options */
- |>
- |> SAY Stem.Label
- |> PULL Resp
- |> FOR i = 1 TO Stem.0 DO
- |> IF Resp = Stem.i THEN
- |> LEAVE
- |> END /* i */
- |>
- |> IF i = Stem.0 + 1 THEN /* Default is Stem.1 */
- |> RETURN Stem.1
- |>
- |> RETURN Stem.i
- |>
- |> /* End of example */
- |>
- |> This doesn't work. Nor does GetChoice(Opts.) or GetChoice('Opts') or
- |> GetChoice('Opts.').
- |>
- |> Is there any way to do what I want?
-
- Yes:
- GetChoice: PROCEDURE EXPOSE Opts.0 Opts.1 Opts.2 Opts.3 Opts.4
-
- This is the only way I found with my own script.
- But for me this is not a practicable solution because I have
- such things as guy.name.mail.sent.2
- So I have to have NO procedure at all which could deal with my stem variables.
- Of courses this is dangerous with the name of loop variables and is a very
- good way to introduce bugs.
-
- It would be nice if rexx allows that the components of a stem variable declared
- as EXPOSEd.
-
- So how would it best to deal with the construction of "objects" ?
- For instance, guy is the class name of the object, and name is a variable
- that I use to identify the guy in guy.name Knowing thew guy I can then
- allow him a password for instance : guy.name.passwd
- But If I have to declare guy.name.passwd and not change name nor passwd
- in any procedure I will soon come to BIG PUZZLES too!
-
- Anothe problem is that I have difficulty with avoidind painful select loop
- with construct like :
- /* assgin name of functions to stem var */
- choice.quit = myQUIT
- choice.read = myREAD
- choice.write = myWRITE
- say "choice ?"
- parse pull this
- call choice.this /* doesn't work - I tried variations but to no avail
- (value, interpret) */
-
- This is really a big trouble to me.
-
- How would you then deal with that, you experimented rexx users ?
-
- I too would greatly appreciate any help.
-
- Jean-Pierre Riviere
- LRI - Univ. Orsay
- jpr@lri.lri.fr
- --
- Jean-Pierre RIVIERE | ///
- LRI - Universite Paris Sud | \\\///
- e-mail : jpr@lri.lri.fr | \///
-