How pass compound vars to subroutine? 
Author Message
 How pass compound vars to subroutine?

I have a set of compound variables, and I wish to pass
each one of these in turn to a subroutine to have the
same operation done on each.
 I don't seem to be able to do this.
 My subroutine starts
        ARG dummy
and I refer to the compound variable within the routine
as      dummy.tail
and I call the routine with the name of the stem part of
the compound variable as the parameter.
but Rexx does not seem to recognise references to dummy.tail
as references to an existing compound variable.
 If the language does not permit this, how can I easily achieve
what I am trying to do (effectively call by reference on the
stem name)?
--
Robin Walker        (Network Admin), Queens' College, Cambridge, CB3 9ET, GB



Mon, 04 Nov 1996 19:37:20 GMT  
 How pass compound vars to subroutine?

Quote:
> I have a set of compound variables, and I wish to pass
> each one of these in turn to a subroutine to have the
> same operation done on each.
>  I don't seem to be able to do this.
>  My subroutine starts
>         ARG dummy
> and I refer to the compound variable within the routine
> as      dummy.tail
> and I call the routine with the name of the stem part of
> the compound variable as the parameter.
> but Rexx does not seem to recognise references to dummy.tail
> as references to an existing compound variable.
>  If the language does not permit this, how can I easily achieve
> what I am trying to do (effectively call by reference on the
> stem name)?
> --
> Robin Walker        (Network Admin), Queens' College, Cambridge, CB3
9ET, GB


335566

I asked someone at IBM the same question about two years ago. The answer I
got then was that REXX doesn't allow this, but maybe one day it will. For
the time being, you have to make do with using global variables in your
subroutines.



Tue, 12 Nov 1996 00:53:44 GMT  
 How pass compound vars to subroutine?

Quote:

>> I have a set of compound variables, and I wish to pass
>> each one of these in turn to a subroutine to have the
>> same operation done on each.
>>  I don't seem to be able to do this.
>>  My subroutine starts
>>         ARG dummy
>> and I refer to the compound variable within the routine
>> as      dummy.tail
>> and I call the routine with the name of the stem part of
>> the compound variable as the parameter.
>> but Rexx does not seem to recognise references to dummy.tail
>> as references to an existing compound variable.
>>  If the language does not permit this, how can I easily achieve
>> what I am trying to do (effectively call by reference on the
>> stem name)?
>> --
>> Robin Walker        (Network Admin), Queens' College, Cambridge, CB3
>9ET, GB

>335566

>I asked someone at IBM the same question about two years ago. The answer I
>got then was that REXX doesn't allow this, but maybe one day it will. For
>the time being, you have to make do with using global variables in your
>subroutines.

Here's a cheezy program which I believe accomplishes what was asked:

/* */
line.0 = 2
line.1 = 'lo'
line.2 = 'and behold'

call mystuff 'line'
say "---"   /* separate results */
do i = 1 to line.0
  say line.i
end

exit 0

mystuff: nop
        arg str
        interpret 'len = 'str'.0'
        say 'length = 'len
        do i=1 to len
           interpret 'val= 'str'.'i
           say val
        end
        interpret str'.0='str'.0+1'
        interpret str'.'i'="hello"'
        return

The output (on OS/2 REXX) is:
length = 2
lo
and behold
---
lo
and behold
hello

Note: using interpret is scary.  This is NOT how I would really
want to perform pass by reference.  It's really more like pass by
name.  Also, you could not declare this subroutine as a "procedure".
So much for allowing recursion!

Any other thoughts?

Ron Perrella
The opinions expressed here are my own and not necessarily that of my
employer.



Tue, 12 Nov 1996 21:10:48 GMT  
 How pass compound vars to subroutine?

Quote:


>> I have a set of compound variables, and I wish to pass
>> each one of these in turn to a subroutine to have the
>> same operation done on each.
>>  I don't seem to be able to do this.
>>  My subroutine starts
>>         ARG dummy
>> and I refer to the compound variable within the routine
>> as      dummy.tail
>> and I call the routine with the name of the stem part of
>> the compound variable as the parameter.
>> but Rexx does not seem to recognise references to dummy.tail
>> as references to an existing compound variable.
>>  If the language does not permit this, how can I easily achieve
>> what I am trying to do (effectively call by reference on the
>> stem name)?
>> --
>> Robin Walker        (Network Admin), Queens' College, Cambridge, CB3
>9ET, GB

>335566

>I asked someone at IBM the same question about two years ago. The answer I
>got then was that REXX doesn't allow this, but maybe one day it will. For
>the time being, you have to make do with using global variables in your
>subroutines.

From what I hear this feature is avaliable in Object Rexx as is
returning stems from a function. But unfortunately since you can't get
Object Rexx at the moment that info isn't mcuh use.

Joe.

--
===============================================================================
Joseph Skinner                    | There was a sky that was always gray.

Invercargill, New Zealand         | There was a being that was always sad.
                        |from The Sadness of the Executioner by Fritz Leiber
===============================================================================



Tue, 19 Nov 1996 08:03:21 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. passing functions or subroutines in a subroutine

2. Passing logical variables from Fortran subroutine to C subroutine

3. pass a subroutine (use derived data type) as an argument to another subroutine

4. Passing compound variable contents to a function

5. Passing Compound Variables?

6. How pass compound var

7. passing compound arguments to spawn

8. passing shell vars to gawk

9. passing vars to shell script

10. passing vars to awk script

11. Passing and getting vars. from C to awk

12. HELP: Passing Unix vars to AWK

 

 
Powered by phpBB® Forum Software