IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Passing data between programs


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Wed Dec 22, 2010 10:09 pm
Reply with quote

I know there have been several post about this issue, and Rexx does not offer a easy way of doing it. I was curious about what the forum thought of my process.

First I have a dataset that contains the global variables that will be passed between program.

Code:
RPT.               /* REPEATING BLOCK ARRAY                          */

MAX_ROW            /* DEFAULT SIZE DEPTH                             */
MAX_COL            /* DEFAULT SIZE WIDTH                             */
INIT_CSR           /* DEFAULT CURSOR POSITION                        */

PNL_PREF           /* DEFAULT PANEL NAME PREFIX                      */
PNL_SUFF           /* DEFAULT PANEL NAME SUFFIX                      */


Whenever a program is about to call another program, it will open the global variables dataset and it will create a single string with each parameter appended. Then, it will call the program, passing the parameter string.

Code:
DRAW_PARMS:
  PARMS = ''

  ADDRESS TSO
  "ALLOC DATASET('"DATASET"("GLOBALS")') FILE(PARM) SHR"
  'EXECIO * DISKR PARM (FINIS STEM PARMS.'
  'FREE FILE(PARM)'

  DO I = 1 TO PARMS.0
    PARM = SPACE(SUBSTR(PARMS.I,1,12))

    IF PARM > '' THEN DO
      IF POS('.',PARM) = LENGTH(PARM) THEN DO
        INTERPRET "MAX = "PARM'0'
        CALL CHANGE_STR PARM,'.',''
        PARM = STRING

        DO J = 0 TO MAX
          INTERPRET "PARMS = PARMS PARM'.'J'='"PARM'.'J
        END
      END
      ELSE
        INTERPRET "PARMS = PARMS PARM'='"PARM
    END
  END
RETURN


So in this example, the parameter string will look something like this:

Code:
RPT.0=3 RPT.1=A RPT.2=B RPT.3=C MAX_ROW=24 MAX_COL=80 INIT_CSR=5 PNL_PREF=SCRN PNL_SUFF=MOD2


Then the calling program will parse the parameter string:

Code:
PARSE_PARMS:
  PARMS = ARG(1)

  DO FOREVER
    IF PARMS > '' THEN DO
      PARSE VAR PARMS PARM PARMS
      PARSE VAR PARM PARM_NAME '=' PARM_VAL .

      IF POS('~',PARM_VAL) > 0 THEN
        PARM_VAL = TRANSLATE(PARM_VAL,' ','~'

      IF LENGTH(PARM_VAL) > 0 THEN DO
        IF POS("'",PARM_VAL) > 0 THEN DO
          PARM_VAL = '"'PARM_VAL'"'

          INTERPRET PARM_NAME "="PARM_VAL
        END
        ELSE
          INTERPRET PARM_NAME "='"PARM_VAL"'"
      END
      ELSE
        INTERPRET PARM_NAME "='"PARM_VAL"'"
    END
    ELSE
      LEAVE
  END
RETURN
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Dec 22, 2010 10:50 pm
Reply with quote

Yep, I've done that myself.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Fri Dec 24, 2010 11:44 am
Reply with quote

Code:
PARSE VAR PARMS PARM PARMS
This restricts you to numeric values or single word text values. I suggest you use a delimiter other than blank. I have seen '05'x used for that a few times.

Code:

Do while (parms ^= '')
  PARSE VAR PARMS PARM '05'x PARMS
  INTERPRET parm
End
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Dec 24, 2010 11:47 am
Reply with quote

Code:
RPT.0=3 RPT.1=A RPT.2=B RPT.3=C MAX_ROW=24 MAX_COL=80 INIT_CSR=5 PNL_PREF=SCRN PNL_SUFF=MOD2

why not separate the assignments wit a ";" and interpret in one shot the whole string??
no parsing needed!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
Search our Forums:

Back to Top