passing stems to external rexx programs

Help
2003-10-21
2003-10-23
  • Marco Capalbo

    Marco Capalbo - 2003-10-21

    I want to put a subroutine in a separate file (running w2000) and pass it a stem as an argument.

    Here's what happens. The following is the main program:

    x.1 = 999

    CALL extworld x
    CALL intworld x
    EXIT

    intworld:

        SAY "internal world"

        PARSE ARG a .

        INTERPRET "lookx ="a".1"
        SAY lookx

    RETURN

    ---external file "extworld.rex" begins here
    SAY "external world"

    PARSE ARG a .

    INTERPRET "lookx ="a".1"
    SAY lookx

    RETURN
    ---end of external file

    the program prints:
    external world
    X.1
    internal world
    999

    is there any way to do this?? i have tried making extworld a PROCEDURE and with EXPOSE, but no joy.

    is there a better (other?) way to pass different stems as arguments?
    i have always used the "internal world" method.

    thanks in advance.

     
    • Robert A "Bob" Cruz

      I regret to inform you that there is no straight-forward mechanism for passing a stem to an external routine.

      One way around this is for the calling routine to write a file containing the values from the stem, and then the called routine would read the values back in.  The GLOBAL command in CMS makes this easier, but it is not generally available on other platforms.  For small collections, you could pass them as environment variables.

      Good luck!

       
      • Andy Willie

        Andy Willie - 2003-10-23

        I agree with bob_cruz.
        Here's a little routine to do a c-like include. I have found it useful to have several rexx's use the same variables with initial values. I define them in an include file (like a *.h header file in c). You could write this intermediate file with your stem variables and values, then call include from your subroutine.

        Hope this helps...
        /*--- Include a file containing Rexx variable assignments ---*/
        Include:
           parse upper arg file
           if ( file = '' ) then return( 0 )
           /* if ( file does not exist ) then do */
              /* error */
              /* or return */
           /* end */

           /*--- Loop until end of input file ---*/
           do while ( Lines( file ) \= 0 )

              /*--- Read a line ---*/
              line = Strip( Linein( file ) )

              /*--- Skip blank lines and comments that start with an asterisk ---*/
              if ( line = '' | Left( line, 1 ) = '*' ) then iterate

              /*--- Execute the input line ---*/
              Interpret( line )
           end

           call Stream file, 'C', 'CLOSE'
        return

         

Log in to post a comment.