Passing stems - help 
Author Message
 Passing stems - help

Quote:

>I am trying to pass a stem variable into a procedure as follows:
>------------------------------------------------------------------

(Example deleted)

Quote:
>I would like it to print the contents of fred.1, fred.2 and fred.3 but
>instead it tries to print stem.1 etc. Has anybody any idea how to do this?
>Thanks in advance.
>Richard

Okay, Richard,

In order to be able to process a stem in a subordinate routine you do not need
to pass it as a formal parameter, 'cause variables in Rexx are by definition
global. So in your example there seems to be no need for passing it as a
parameter.

There are situations, however, that one would like to enforce this. In that
case the subordinate procedure or function should have the 'Procedure' verb as
first verb. This effectively makes all variables that are defined outside
itself, hidden. You can than decide to make a selection of global variables
and declare them to be known within your 'Procedure', by using the 'Expose'
verb.

Again, this only is a work-around of what might be your actual question.

To pass a stem as a formal parameter try coding:

        Call Subroutine Fred.     /* --- and that should work --- */

- or -

        x = Sub_Function(Fred.)     /* --- That should work also --- */

Hope this helps. Let me know if you want...



Fri, 11 Jul 1997 04:05:38 GMT  
 Passing stems - help

Quote:

> >  I am trying to pass a stem variable into a procedure as follows:
> >  ------------------------------------------------------------------
> >  fred.0 = 3
> >  fred.1 = "red"
> >  fred.2 = "blue"
> >  fred.3 = "green"
> >  call PrintStem "fred"
> >  exit

> >  PrintStem:
> >      stem = arg(1)
> >      do i = 1 to stem.0
> >          say stem.i
> >      end
> >  return

If I'm coding this program what I will code is like this:

fred.0 = 3
fred.1 = "red"
fred.2 = "blue"
fred.3 = "green"
call PrintStem    
exit

PrintStem: procedure expose fred.
stem = arg(1)
do i = 1 to stem.0
   say stem.i
end
return

I'm not sure though if this is acceptable (coding style or your REXX
interpreter).  This works in MVS/TSO.



Sat, 12 Jul 1997 13:40:17 GMT  
 Passing stems - help

Quote:

>  Subject: Passing stems - help

>  I am trying to pass a stem variable into a procedure as follows:
>  ------------------------------------------------------------------
>  fred.0 = 3
>  fred.1 = "red"
>  fred.2 = "blue"
>  fred.3 = "green"
>  call PrintStem "fred"
>  exit

>  PrintStem:
>      stem = arg(1)
>      do i = 1 to stem.0
>          say stem.i
>      end
>  return
>  ------------------------------------------------------------------
>  I would like it to print the contents of fred.1, fred.2 and fred.3 but
>  instead it tries to print stem.1 etc. Has anybody any idea how to do this?

J Tiller has the answer, but you can use Interpret (In TSO/E-ReXX anyway,)
to get values into variables as well as out.
E.g.  (Add dots as appropriate for your application)
/* REXX */
/* uses an array with vars data1, data2, etc.
Useful if you are using ISPF Panels and Skeletons, and wish to pass
arrays of vars to them, but cant use data.1, data.2, etc */

varstem = 'data'

/* Put variables data1 - data10 into ISPF profile, and drop them from REXX
   environment */
do i = 1 to 10
   var = varstem||i
   interpret var '= i*i'
   interpret 'address ispexec "vput ('var') profile"'
   interpret 'drop 'var
end

/* Ressurect the array from the ISPF profile, and print it */
do i = 1 to 10
   var = varstem||i
   interpret 'address ispexec "vget ('var')"'
   interpret 'say 'var
end
--
  _____     __    _   _             __
 (     )   '  )  (     )           '  )
  )   / _  o /    )---/ _  _  _ _  _ /__
 (_  (_(-'/ (_   (_  (_(_l/ )(_(_)(_/(_
G22c, The Met Office, London Rd, Bracknell, RG12 2SZ.


Voice        : (0344) 856944



Tue, 08 Jul 1997 17:13:34 GMT  
 Passing stems - help
[snip]

Quote:
>PrintStem: procedure expose fred.
>stem = arg(1)
>do i = 1 to stem.0
>   say stem.i
>end
>return
>               This works in MVS/TSO.

Surely not?

The simple symbol "stem" is (or should be) completely separate from the stem
symbol "stem."  and setting one does not affect the behaviour of the other.
The previously posted solutions involving the "value" built-in function have
been the correct ones.

Ian Collier - Departmental Lecturer (and perpetual postgrad student) -

Building, Parks Road, Oxford OX1 3QD - WWW Home Page (including REXX
section): http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html



Sun, 13 Jul 1997 19:53:01 GMT  
 Passing stems - help

Quote:
>    Call Subroutine Fred.     /* --- and that should work --- */
>    x = Sub_Function(Fred.)     /* --- That should work also --- */

The effect of these instructions is to pass as a single argument the string
"FRED.", or, if a previous assignment of the form

   fred. = somestring

has been executed, the value of somestring.

Ian Collier - Departmental Lecturer (and perpetual postgrad student) -

Building, Parks Road, Oxford OX1 3QD - WWW Home Page (including REXX
section): http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html

New to this group?  Answers to frequently-asked questions can be had from
ftp://rexx.uwaterloo.ca/pub/rexxfaq.txt .



Fri, 18 Jul 1997 21:07:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Passing stems - help

2. Passing stem variables

3. Passing stem variables to external routines

4. How to pass stems to a user-defined function

5. Passing stems between REXX and C/C++

6. Passing REXX stems to external REXX functions -Reply

7. Passing REXX stems to external REXX functions

8. Passing stem variables into REXX functions

9. Passing Stems to external functions

10. Passing Stems in Regina

11. Passing and returning stem variable values.

12. Q: Passing stem array to external function?

 

 
Powered by phpBB® Forum Software