Sample REXX EXEC (Scripting)
The below figure is a sample REXX EXEC to log a user onto TSO, issue =x at the ISPF Primary Option Menu, and issue logoff at the TSO READY prompt to terminate the session. Calls to the “display” subroutine are made after each type and send request to show the current screen contents. This EXEC can be found in member CPIREXX of INSTALL.
Sample REXX EXEC
PURPOSE: DEMONSTRATE THE USE OF HSCPI Before you can use this REXX example, you
need to do the following:
1. Follow the Install Instructions for the HSCPI (refer to "Define a Function
Package Directory for REXX CPI" in the Hiperstation Installation Guide.
2. Allocate the HPERIN and HPEROUT DDs to your TSO session. See “DD Requirements”
on page 3-2 for more information.
3. Allocate the HPERLIB DD if you want to be able to run Hiperstation scripts
within REXX.
"ALLOC F(HPERIN) DSNAME(’USERAB0.REXX.EXEC(CONTROL)’) SHR REUSE"
"ALLOC F(HPEROUT) DSNAME(’USERAB0.REXX.EXEC(HIPROUT2)’) SHR REUSE"
/* REXX */
y = ’TSO’ /* data can be in a variable */
x = hscpi(’logon’,’SESID’,y)
say ’session ID is:’ SESID /* what is our session ID? */
say ’return from logon:’ x /* a little trace */
x = hscpi(’type’,’SESID’,2,2,,’TSOHP22’) /* type in userID */
say ’return from type:’ x
call display SESID
x = hscpi(’send’,’SESID’,’enter’) /* send data with enter key */
say ’return from send:’ x
call display SESID
x = hscpi(’type’,’SESID’,8,21,,’BLUE’) /* type in password */
say ’return from type:’ x
call display SESID
z = ’enter’
x = hscpi(’send’,’SESID’,z) /* send data with enter key */
call display SESID
x = hscpi(’send’,’SESID’,’enter’) /* get rID of *** */
call display SESID
x = hscpi(’type’,’SESID’,2,15,,’=X’) /* put =x on ispf main menu */
say ’return from type:’ x
call display SESID
x = hscpi(’send’,’SESID’,’enter’)
call display SESID
x = hscpi(’type’,’SESID’,2,2,,’logoff’) /* logoff at ready prompt */
say ’return from type:’ x
call display SESID
x = hscpi(’send’,’SESID’,’enter’)
call display SESID
x = hscpi(’logoff’,’SESID’)
say ’return from logoff:’ x
exit
display: procedure /* display current screen image */
arg SESID
x = hscpi(’retrieve’,’SESID’,0,0,0,’DATA’,1920)
DATA = translate(DATA, ’ ’,’01 02 03 04 05 06 07 08 09’x)
do x = 24 to 1 by -1 /* remove attribute at start of each line *1
z = ((x-1)*80)+1
DATA = delstr(DATA,z,1)
end
say ’session ID is:’ SESID
say DATA
return
"FREE F(HPERIN)"
"FREE F(HPEROUT)"
need to do the following:
1. Follow the Install Instructions for the HSCPI (refer to "Define a Function
Package Directory for REXX CPI" in the Hiperstation Installation Guide.
2. Allocate the HPERIN and HPEROUT DDs to your TSO session. See “DD Requirements”
on page 3-2 for more information.
3. Allocate the HPERLIB DD if you want to be able to run Hiperstation scripts
within REXX.
"ALLOC F(HPERIN) DSNAME(’USERAB0.REXX.EXEC(CONTROL)’) SHR REUSE"
"ALLOC F(HPEROUT) DSNAME(’USERAB0.REXX.EXEC(HIPROUT2)’) SHR REUSE"
/* REXX */
y = ’TSO’ /* data can be in a variable */
x = hscpi(’logon’,’SESID’,y)
say ’session ID is:’ SESID /* what is our session ID? */
say ’return from logon:’ x /* a little trace */
x = hscpi(’type’,’SESID’,2,2,,’TSOHP22’) /* type in userID */
say ’return from type:’ x
call display SESID
x = hscpi(’send’,’SESID’,’enter’) /* send data with enter key */
say ’return from send:’ x
call display SESID
x = hscpi(’type’,’SESID’,8,21,,’BLUE’) /* type in password */
say ’return from type:’ x
call display SESID
z = ’enter’
x = hscpi(’send’,’SESID’,z) /* send data with enter key */
call display SESID
x = hscpi(’send’,’SESID’,’enter’) /* get rID of *** */
call display SESID
x = hscpi(’type’,’SESID’,2,15,,’=X’) /* put =x on ispf main menu */
say ’return from type:’ x
call display SESID
x = hscpi(’send’,’SESID’,’enter’)
call display SESID
x = hscpi(’type’,’SESID’,2,2,,’logoff’) /* logoff at ready prompt */
say ’return from type:’ x
call display SESID
x = hscpi(’send’,’SESID’,’enter’)
call display SESID
x = hscpi(’logoff’,’SESID’)
say ’return from logoff:’ x
exit
display: procedure /* display current screen image */
arg SESID
x = hscpi(’retrieve’,’SESID’,0,0,0,’DATA’,1920)
DATA = translate(DATA, ’ ’,’01 02 03 04 05 06 07 08 09’x)
do x = 24 to 1 by -1 /* remove attribute at start of each line *1
z = ((x-1)*80)+1
DATA = delstr(DATA,z,1)
end
say ’session ID is:’ SESID
say DATA
return
"FREE F(HPERIN)"
"FREE F(HPEROUT)"
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*