Professional Documents
Culture Documents
REXX
WIPRO TECHNOLOGIES
REXX/WIPRO TECH
SESSION ONE
REXX BASICS
INTRODUCTION TO REXX ADVANTAGES OF REXX CODING RULES EXECUTING A REXX EXEC TALKING TO THE ENVIRONMENT
REXX/WIPRO TECH 2
INTRODUCTION.
REXX is the most exciting language youll find on IBMs mainframe systems. Rexxs main function is to pass commands to TSO or the dialogue Manager of TSO/ISPF. Rexx is more than just a facility that lets you put TSO commands into a procedure; its a full-fledged programming language. It lets you create variables and use them in expressions to perform calculations or test specific conditions. Rexx provides a full set of control instructions, including IF-THEN-ELSE and a powerful DO instruction. It allows you to communicate with terminal user by displaying messages and accepting data from keyboard.
REXX is an interpreted language rather than a compiled language. As a result , you dont have to compile and link-edit a REXX exec before you can use it, instead the interpreter reads and interprets the instructions in your exec one at a time.
REXX/WIPRO TECH 3
ADVANTAGES OF REXX.
A. MAIN FUNCTION OF REXX. REXXs main purpose is to pass commands to tso and/or the dialogue manager of TSO/ISPF. B. AUTOMATING REPETITIVE TASKS. Instead of keying a series of commands over and over again you can place these commands within a REXX program and then REXX can pass these commands to TSO or TSO/ISPF. This eliminates keying errors. C. INTERACTING WITH THE DIALOGUE MANAGER. The TSO/ISPF Dialogue manager allows you to create and display custom-made panels. So using REXX you can create sets of panels or menus, much like ISPF itself ! D. CREATING NEW COMMANDS. With REXX you can create programs that behaves as if they are new TSO commands. You can execute these programs by typing the name just like any other TSO command while you are in Line mode TSO. If you are in ISPF you must preface your command with TSO , so ISPF will know you are not talking to it but to TSO. E. PERSONAL PROGRAMMING. REXX is so easy , you can use it for those short (or long !) programs that helps you in everyday affairs.
REXX/WIPRO TECH 4
CODING RULES
In general there are no column rules for REXX. Start your program in any column and continue in any column you choose. Words should be separated by one or more spaces. Start the programs with a command line like this /* REXX SAMPLE PROGRAM*/ It says us this is a sample REXX program, it also say the same thing to TSO. TSO sees the word REXX and knows that it a REXX program not a CLIST. You may have comments anywhere in your program.
Components of REXX
Rexx is broken down into seven components. Keywords, Assignment statements, Literal, Variable, Command, Label and Function. l Key words. Like most other languages REXX has verbs with specific meaning, each verb is a keyword and is found first in the sentence. E.g.. Address, ARG, CALL, DO, NOP etc... l Assignment. First component in this feature is a variable may not be in quotes. The variable is made equal to whatever is the right of the equal sign.
A=5 TOTAL = 5 + 25 NAME = AISH REXX/WIPRO TECH 5
Literal. Stands for literal, literals are normally enclosed in quotes or apostrophes. Although REXX can
interpret a literal as such if you forget the quotes or apostrophes. REXX will first look the string of character is a variable if it is then REXX uses the contents of the variable else REXX takes the character string as a literal, but will convert it to upper case.
GOOD DAY GOODBYE 12345 F1F2F3X (hex string)
If you need apostrophe in a literal as in the name OConnor , you can use either one of the following ways. OConnor O Connor You can put a plus sign or minus sign in front of a numeric literal then REXX will never treat it as a mere character string. In REXX you can have quotes or apostrophes for numeric literals. This means 1243 is legal in REXX. In REXX a literal may be up to 251 characters in length. You can concatenate two literals to produce a longer one
LONG_VAR = LONG STRING TO END OF LINE ||, REST OF STRING ON NEXT LINE LONG_VAR = LONG STRING TO END OF LINE, REST OF STRING ON NEXT LINE
If you put the letter X after a literal in quotes or apostrophes, REXX will take it as a hex string M Any time you put an X after a quoted string , REXX takes it as a hex string , This will lead into syntax errors X = 12 + 22 /* syntax error : attempts hex interpretation*/
REXX/WIPRO TECH 6
Variable. The variable holds information which may change during the program execution.
A B NAME EMP_ADDRESS RECORD.I
Variable names must begin with a letter and may as long as 250 characters. Underscore character can be used , period is not allowed. A variable that was never given a value is taken as a literal but converted into upper case. Command. Command is something that is understood by the operating system such as TSO. REXX passes it to TSO for TSO to process.
ALLOCATE LOGOFF LISTCAT SEND HDX WELCOMES YOU USER(T12089)
REXX/WIPRO TECH
Label. Label is used to name a subroutine, user-written function, or a error trap, or target of a
transfer of control instruction. A label must be the first thing on the line and end with a colon.
COMPUTE: SUBROUTINE1: ERROR: HERE:
REXX/WIPRO TECH
*/ */
ADDRESS ISREDIT (SAVESTAT) = USER_STATE /* for ISPF editor CHANGE ALL B N /* for ISPF editor
*/ */
REXX/WIPRO TECH
10
If most of your commands are for the same environment , but one command in particular is meant for a different environment, you can use the following way this will not change the default environment.
ADDRESS ISPEXEC DISPLAY PANEL(PAN123) /* for ISPF */
The word for ADDRESS is taken as a literal, even if no quotes or apostrophes are used. If you want to use a variable here, use the keyword VALUE or put the variable in parentheses as shown below.
Environment = ISPEXEC ADDRESS VALUE Environment ADDRESS (Environment) /* Put ISPEXEC in var */ /* use var in command */ /* use var in command */
IS AN ENVIRONMENT AVAILABLE ?
Before passing a command to an environment, you can find out if that environment is available. TSO sub command SUBCOM asks TSO is the desired subcommand environment is available, if available TSO will return a RC of 0.
SUBCOM ISPEXEC IF RC = 0 THEN DO ADDRESS ISPEXEC DISPLAY PANEL(PANEL1) END REXX/WIPRO TECH 11
SESSION TWO
ESSENTIAL VERBS
I/O instruction (Parse External, Say) Concatenation of strings with & without spaces. String manipulation. Arithmetic Operation(Binary, Unary). Boolean Operators.
REXX/WIPRO TECH 12
I/O INSTRUCTIONS
Parse : Upper : Origins : Template : This is the instruction This is optional, specified data will be converted to upper case. arg, pull, external, var, value, source, version. Tells REXX hoe to split up the data and put the variables in the template.
In session 2 we will see only PARSE EXTERNAL, Remaining we will cover down the line.
PARSE EXTERNAL
Parse external will take information from the terminal not from the stack Parse external is equivalent to Accept in COBOL. Use it when you dont to access STACK. Eg: Parse upper external name It expects the user to type the name in the terminal and since upper is specified the input will change to upper case REXX/WIPRO TECH 13
SAY....
Syntax: SAY STRING OR VARIABLE
It displays a line on the terminal, consisting of string or variable It is equivalent to DISPLAY command in COBOL. When literal is used use double quotes .
say hello welcome to rexx hello welcome to rexx will be displayed in the terminal. 2. A=23 say A The value of 23 will be displayed in the terminal. Say enter your name parse upper external name say thank you, name say for entering your name Eg:1. REXX/WIPRO TECH 14
3.
EG:
1.
2.
giri
REXX/WIPRO TECH
15
If two items next to each other with one or more spaces between them, one space remain. One or more spaces become one space. giri
REXX/WIPRO TECH
16
STRING MANIPULATION
The topic to be covered (except Parse External)
Abbreviations of Parse Function of Parsing. Parsing Argument in a main program. Parsing Argument in a function or subroutine. Parsing from the stack and terminal. Parsing a variable. Parsing a literal;value.
REXX/WIPRO TECH
17
REXX allows the users to abbreviate instructions like Parse upper arg to simply arg. Similarly users can say simply PULL instead of Parse upper Pull
Functions of Parsing
Parse takes data from the origin it may be command line, TSO stack, Terminal, variable, literal. Passes the data to template. Distributes the data to the variables. When Parse instructions is executed all the variables are changed even variables receives NULL
REXX/WIPRO TECH 18
The main program is executed from option 6 from ISPF, Native TSO and command line in ISPF. Parse upper arg receives anything typed next to REXX program when you execute. Information is passed to the variables that you specify on the Parse upper arg.
Parse upper arg A B C D SAY B C D A /*Displays welcome to rexx hello */ Parse upper arg may be abbreviated as ARG . The above example may be use arg instead of parse upper arg.
REXX/WIPRO TECH 19
Parse Arg or Arg instruction is also used in a user-written function or subroutine. The main difference is that you may use COMMAS between variables.
/* rexx program CALL MYPROGRAM 1, 2 SAY RESULT EXIT MYPROGRAM: PARSE ARG A , B RETURN A + B */
REXX/WIPRO TECH
20
Normally there is nothing in the stack, so this instruction is to get information from the terminal. If there is nothing in the stack, parse upper pull receive any information from terminal.
Terminal GIRIDHAR
STACK
Say please enter your name pull name say thank you, name say for entering your name
REXX/WIPRO TECH 21
A Variable may contain string of characters consisting of any number of words, spaces etc.., By parsing a variable user can split up its contents into one or more other variables.
Name = Giridhar G babu PARSE VAR NAME FIRST MIDDLE LAST SAY YOUR LAST NAME IS LAST.
Parsing a literal:value
Parse value with a literal and function. REXX needs keyword WITH so it can tell where the template begin. Eg., Parse value this is a sample with a b c d Parse value date( ) with day month year This eg., uses built-in function date to get the date.
REXX/WIPRO TECH 22
BOOLEAN OPERATORS
Boolean operators allow you to do more than one comparison. REXX uses Boolean Operators like AND, OR, EXCLUSIVE OR. Use only symbols not words.
REXX/WIPRO TECH
23
AND.
OR; either one or both. Exclusive OR; one is true, not both.
Eg., 1.
if today =Monday | today = Tuesday THEN SAY holiday. 2. If Employee_a = engineer &&, Employee_b = engineer with computer knowledge THEN SAY youre employed ELSE SAY Over qualified 3. If <cond1> && <cond2> THEN SAY one condition is true Else Say both condition are true or false
REXX/WIPRO TECH
24
SESSION THREE
PROGRAMMING TECHNIQUES
IF CONDITION SELECT CASE STRUCTURE
IF CONDITION....
Topics to be covered
IF Syntax Key points to remember Using NOP More than one instruction
REXX/WIPRO TECH 26
IF Syntax....
1. IF THEN IF comparison THEN one-instruction ELSE one-instruction IF comparison THEN instruction; ELSE instruction. English words such as EQUAL, AND, OR are not allowed THEN is required THEN is followed by one instruction or by a DO ... END sequence NOP may be used as a do nothing instruction ELSE is not required. If coded, it is followed by one instruction or by a DO...END sequence IF THEN ELSE should be on separate lines comparison one-instruction 2.
3.
Using NOP
Sometimes you dont want to do anything at all when a condition is true, but want to do something when a condition is false. In that case, you can use the verb NOP. Using NOP after ELSE is not useful, except in a nested IF to ensure that every IF has its own ELSE.
REXX/WIPRO TECH
28
30
modifiers
DO
modifiers
WHILE UNTIL
variable =
FOREVER FOR
number
REXX/WIPRO TECH 32
THE DO WHILE
WHILE continues the loop as long as something is true. It checks before doing the loop the first time and may not execute it even once.
The DO WHILE DO WHILE something is true instructions END An example of DO WHILE DO WHILE TIME ( ) <17:01:00 SAY WORK END
THE DO UNTIL
UNTIL loops up to the moment when something becomes true. It checks at the END, but doesnt check before the first time. It will normally do the loop at least once.
EXAMPLE OF DO UNTIL DO UNTIL TIME > 17:00:00 SAY WORK END REXX/WIPRO TECH
33
As shown in the next example you can also step through a variable without a limit. You will have to stop the loop with LEAVE.
DO I = 1 SAY I IF I > 1000 THEN LEAVE END
If you ask REXX to do something impossible, it will just ignore and not do the loop even once.
LOOPING FOREVER
You can loop forever without any limit at all with FOREVER. However, you do have to get out sometime, and so will have to use LEAVE . Do not use SIGNAL to do this.As shown in example LEAVE sends control after the END.
DO FOREVER IF TIME ( ) > 12:01:00 THEN LEAVE SAY IS IT LUNCH YET? END
*/
ITERATE goes back to the beginning of the repetitive loop it is in. In the next example, control goes back to the DO I even though the ITERATE is a nonrepetitive DO END sequence.
DO I = 1 TO 4 IF I = 3 THEN DO SAY GOING TO ITERATE ITERATE SAY I END END I /* the output is 1 2 GOING TO ITERATE 4 REXX/WIPRO TECH
*/
37
If you are in a nested loop, you can specify the control variable of the inner loop or outer loop. You will skip back to the beginning of whichever one you specify.
REXX/WIPRO TECH 38
STYLES IN LOOPING....
Where possible end a loop with the same variable you began it with.
DO I = 6 ..... END I
Use comments to match DOs and ENDs. Make the main line of your program a DO loop. If you need to exit from a loop, use LEAVE.
DO 1000 /* instructions */ IF condition THEN LEAVE END /* 1000 */
Nest loops if you wish, but not more than three levels
DO I = 1 TO 6 DO J = 1 TO 5 DO K = 1 TO 7 SAY I J K END K END J END I
39
SESSION FOUR
DATA HANDLING
STACK & QUEUE LIFO & FIFO COMPOUND VARIABLE INTERPRET INSTRUCTION PRECISION
REXX/WIPRO TECH 40
TSO STACK
STACK:
Stack is Temporary buffer like storage area managed by TSO. It is created at the moment you start running any REXX program and is available to any other REXX program you may call or execute from within your program. Note: It is not applicable to CLIST or COBOL programs. It can be used by TSO command that prompt for it. (Explained in macro session).
REXX/WIPRO TECH
41
Pull
DESCRIPTION OF STACK:
TSO stack has two parts: Terminal buffer. Program buffer.
Terminal
Terminal buffer
Program stack
REXX/WIPRO TECH
42
ENTERING
DATA 5 DATA 4
COMING OUT
DATA 3
DATA 2 DATA 1
STACK
REXX/WIPRO TECH
43
ENTERING
DATA 5
DATA 4
DATA 3 DATA 2 DATA 1
COMING OUT
REXX/WIPRO TECH
44
Isolating a stack
The stack create through new stack command can be deleted using DELSTACK command. So that data that was present in the new stack will also be deleted after the deletion of the old stack
REXX/WIPRO TECH
45
QUEUED( )
It is a function used to return number of elements in the stack.
REXX/WIPRO TECH 46
COMPOUND VARIABLE
Compound variable is a two part variable with parts separated by a period. Temperature.A is a compound variable. The left part before the period is the stem(which is the variable) and the right part after the period is a extension(which is a variable) First REXX checks the extension whether it is a variable if it is REXX treats the combination as a variable else it treats it as a single variable.
REXX/WIPRO TECH
47
INTERPRET INSTRUCTION
Interpret makes REXX to process an Expression as an Instruction. Eg., A = say hello Interpret A ( If A is a valid REXX instruction, it is executed. ) HELLO ( This is displayed)
REXX/WIPRO TECH
49
PRECISION
REXX will normally carry out arithmetic with default precision of 9. If you give more than 9 digits, it will have to do some rounding. Eg., 1234567809 Actual number 10 digits. 1234567810 Rounded number. Displayed 1.23456781E+9
SESSION FIVE
ADVANCE CONCEPTS
FUNCTIONS SUBROUTINES PASSING INFORMATION THROUGH A VARIABLE USING PROCEDURE INSTRUCTION EXAMPLES
REXX/WIPRO TECH 51
Internal :
The routine is with in the current exec, marked by a label and used only by the exec.
REXX/WIPRO TECH
52
Calling a subroutine
To call a subroutine, use the CALL instruction followed by the subroutine name (label or exec member name) and optionally followed by up to 20 arguments separated by commas. The subroutine call is an entire instruction CALL subroutine_name arg1, arg2,...
Calling a Function
To call a function, use the function name (label or exec member name) immediately followed by parenthesis that can contain arguments. There can be no space between the function name and the parenthesis. The function call is a part of an instruction. Example : x = function(arg1,arg2,...)
REXX/WIPRO TECH
53
REXX/WIPRO TECH
54
For example, the built in function SUBSTR can be called as either a function or a subroutine. As a function, you invoke it as follows to shorten a word to its first eight characters: x = SUBSTR(verylongWord,1,8) /* x is set to verylong*/
As a subroutine you would get the same results with the following instructions: CALL SUBSTR verylongWord,1,8 /* x is set to verylong*/ x = RESULT When deciding whether to write a subroutine or a function, ask yourself the following questions : Is a returned value optional ? If so, write a subroutine Do I need a value returned as an expression with in an instruction ? If so, write a REXX/WIPRO TECH 55 function.
Writing a Subroutine
A subroutine is a series of instructions that an exec invokes to perform a specific task. The instruction that invokes the subroutine is the CALL instruction. The CALL instruction may be used several times in an exec to invoke the same subroutine. When the subroutine ends, it can return control to the instruction that directly follows the subroutine call. The instruction that returns control is the RETURN instruction. instruction(s) CALL sub1 > instruction(s) EXIT sub1: < instruction(s) RETURN
REXX/WIPRO TECH
56
Subroutines may be internal and designated by a label, or external and designated by the dataset member name that contains the subroutine. The preceding example illustrates an internal subroutine named sub1. IMPORTANT NOTE Because internal subroutines generally appear after the main part of the exec, when you have an internal subroutine, it is important to end the main part of the exec with the EXIT instruction. The following illustrates an external subroutine named sub2.
>REXX.EXEC(MAIN) instruction(s) CALL sub2 instruction(s) . . REXX.EXEC(SUB2) < instruction(s) RETURN
REXX/WIPRO TECH 57
To determine whether to make a subroutine internal or external, you might consider factors such as : Size of the subroutine. Very large subroutines often are external, whereas small subroutines fit easily within the calling exec.
How you want to pass information. It is quicker to pass information through variables in an internal subroutine. Whether the subroutine might be of value to more than one exec or user. If so an external subroutine is preferable.
REXX/WIPRO TECH
58
REXX/WIPRO TECH
59
When an exec and its internal subroutine share the same variables, the value of a variable is what was last assigned, regardless of whether the assignment was in the main part of the exec or in the subroutine. In the following Example, the value of answer is assigned in the subroutine and displayed in the main part of the exec. The variables number1, number2 and answer are shared. /***** REXX *****/ number1 = 5 number2 = 10 CALL subroutine SAY answer /* Displays 15 ***/ EXIT subroutine: answer = number1 + number2 REXX/WIPRO TECH RETURN
60
61
number1 = 10 CALL subroutine SAY number1 number2 EXIT /* Displays 10 number2 subroutine: PROCEDURE number1 = 7 number2 = 5 RETURN
REXX/WIPRO TECH
62
/***********REXX************************************************/ /* This exec uses a PROCEDURE instruction with the EXPOSE option to */ /*expose one variable, number1 in its subroutine. The other variable, number2, */ /*is set to null and displays its name in uppercase */ /****************************************************************/ number1 = 10 CALL subroutine SAY number1 number2 EXIT /* Displays 7 number2 subroutine: PROCEDURE EXPOSE number1 number1 = 7 number2 = 5 RETURN REXX/WIPRO TECH 64
SESSION SIX
ADVANCE CONCEPTS
PASSING INFORMATION BY USING ARGUMENTS USING THE ARG BUILT-IN FUNCTION WRITING A FUNCTION PASSING INFORMATION TO A FUNCTION EXAMPLES
REXX/WIPRO TECH 65
Notice the positional relationships between long and length, and wide and width. Also notice how information is received from variableTECH in the special variable RESULT. REXX/WIPRO perim 67
REXX/WIPRO TECH
68
Good Luck!
REXX/WIPRO TECH 70
/* the computer won */ /* increase the computer score */ /* the user won */ /* increase the user score */
SAY Computer score = computer Your score = user SAY Heads, Tails, or quit? PULL response CALL check /* call internal subroutine, check */ END EXIT
REXX/WIPRO TECH
72
*/ */ */ */
is
*/
/* then returned to the calling exec. */ /**************************************************************************/ ARG input IF input = HEADS THEN userthrow = 0 ELSE userthrow = 1 compthrow = RANDOM(0,1)
/* /*
heads = 0 tails = 1
*/ */
IF compthrow = userthrow THEN outcome = human ELSE outcome = machine RETURN outcome
REXX/WIPRO TECH
Writing a Function
A function is a series of instructions that an exec invokes to perform a specific task and return a value. A function can be built-in or user-written. An exec invokes a user-written function the same way it invokes a built-in function -- by the function name immediately followed by parentheses with no blanks in between. The parentheses can contain up to 20 arguments or no arguments at all. function(argument1, argument2) or function() A function requires a returned value because the function call generally appears in an expression. X = function(arguments1,arguments2.....) When the function ends, it may use the RETURN instruction to send back a value to replace the function call. contd in next slide......
REXX/WIPRO TECH 76
REXX.EXEC(MAIN)
instruction(s) x=func2(arg1) instruction(s) . . . exit
REXX.EXEC(FUNC2)
ARG var1 instruction(s) RETURN value
REXX/WIPRO TECH
78
To determine whether to make a function internal or external, you might consider factors, such as:
Size of the function.: Very large functions often are external, whereas small functions fit easily within the calling exec.
How you want to pass information. It is quicker to pass information through variables in an internal function. Whether the function might be of value to more than one exec or user. If so, an external function is preferable. Performance. The language processor searches for an internal function before it searches for an external function.
REXX/WIPRO TECH
79
REXX/WIPRO TECH
80
SESSION SEVEN
FILES
TOPICS COVERED
FILE HANDLING
WHAT THE PARTICIPANTS WILL BE ABLE TO DO AFTER THE COMPLETION OF THIS SESSION WILL BE ABLE TO READ AND WRITE INTO DISK FILE USING REXX EXECS.
REXX/WIPRO TECH
81
KEY POINTS....
ALLOCATING A FILE WHERE DO YOU READ FROM AND WRITE INTO WHERE DO YOU READ INTO AND WRITE FROM
REXX/WIPRO TECH
82
ALLOCATING A FILE
TSO ALLOCATE COMMAND IS REQUIRED WITHIN THE REXX EXEC TO SPECIFY THE DDNAME FOR THE DATASET THAT IS GOING TO BE USED IN THE FILE OPERATION. ALLOCATE DSN(DATASETNAME) DDN(DDNAME) DISP
DATASET NAME : THE DATASET WHICH CONTAINS THE DATA OR WHERE THE DATA IS TO BE INSERTED
DDNAME : THE LOGICAL NAME TO BE USED IN THE FILE I/O COMMAND : IT CAN HAVE ONE OF THE FOLLOWING CHOICES
NEW (IF THE DATASET IS NEW) OLD (IF THE DATASET IS EXISTING) REXX/WIPRO TECH MOD(IF THE RECORDS ARE TO BE APPENDED)
DISP
83
WHERE DO YOU READ FROM AND WRITE INTO & READ INTO AND WRITE FROM
WE CAN READ FROM AND WRITE INTO A PDS (PARTIONED DATASET) OR PS (PHYSICAL SEQUENTIAL)
WE CAN READ INTO AND WRITE FROM A STACK OR AN ARRAY (COMPOUND VARIABLE)
REXX/WIPRO TECH
84
NOTE: ALTHOUGH IT IS A TSO COMMAND IT CAN BE USED ONLY IN A REXX EXEC (THIS MEANS IT CANNOT BE USED IN THE TSO NATIVE MODE OR AS COMMAND LINE COMMAND OR IN THE READY MODE).
REXX/WIPRO TECH 85
OPERATION ANY OF
: OPERATIONS TO BE PERFORMED IT CAN HAVE THE CHOICES LISTED BELOW DISKR : READ ONLY DISKW : WRITE ONLY DISKRU: READ FOR UPDATE REXX/WIPRO TECH 86
DDNAME
: STANDS FOR THE DDNAME YOU HAVE USED IN THE ALLOCATE COMMAND
SEQ
REXX/WIPRO TECH
87
/************** REXX **********/ ALLOCATE DSN(T13066.REXX.TEST) DDN(INFILE) OLD /* THE DATASET T130066.REXX.TEST IS ALLOCATED TO DDNAME INFILE */ EXECIO * DISKR INFILE (FINIS) /* ALL RECORDS IN THE FILE ARE READ AND PUT INTO STACK */ DO QUEUED() /* QUEUED WILL GIVE THE NO OF RECORDS IN THE STACK */ PULL REC /* FETCHES THE RECORD FROM THE STACK SAY REC /* DISPLAYS THE RECORD ON TO THE SCREEN */ END FREE DDN(INFILE) REXX/WIPRO TECH 88
/**************REXX***********/ ALLOCATE DSN(T13066.REXX.TEST) DDN(INFILE) OLD /* THE DATASET T130066.REXX.TEST IS ALLOCATED TO DDNAME INFILE */ EXECIO * DISKR INFILE (STEM REC.FINIS) /* ALL RECORDS IN THE FILE ARE READ AND PUT INTO AN ARRAY */ C = A.0 /* A.0 WILL HAVE THE NO OF ELEMENTS IN THE ARRAY */ DO I = 1 TO C SAY A.I END FREE DDN(INFILE) /* AFTER THE FILE OPERARTIONS ARE OVER THE DDNAME IS FREED */ REXX/WIPRO TECH
89
90
91
Sample Program
/* REXX */ ALLOCATE DSN(T13066.IU46.REXX) DDN(INFILE) /* DATASET ALLOCATED TO INFILE */ DO FOREVER /* GATHERING RECORDS AND PUTTING INTO QUEUE */ PULL A QUEUE A END EXECIO QUEUED() DISKW INFILE (FINIS) /* WRITING MULTIPLE RECORDS INTO THE FILE */
REXX/WIPRO TECH 92
Sample Program
/* REXX */ ALLOCATE DSN(T13066.IU46.REXX) DDN(INFILE) /* DATASET ALLOCATED TO INFILE */ CONTINUE = YES DO WHILE CONTINUE = YES PULL REC PUSH REC /* PUSHING THE RECORD ONTO THE STACK */ SAY DO YOU WANT TO CONTINUE: YES/NO PULL CONTINUE EXECIO 1 DISKW INFILE /* WRITING ONE RECORD AT A TIME INTO THE FILE */ REXX/WIPRO TECH 93 END
UPDATING A RECORD
EXECIO CAN UPDATE A RECORD IN PLACE.
IT CAN READ A RECORD, ALLOW YOU TO CHANGE IT, AND THEN REWRITE IT. NOTE : YOU CANT JUMP RECORDS BACKWARDS IN A FILE YOU MAY SKIP RECORDS, BUT ONLY IF YOU GO FORWARD.
REXX/WIPRO TECH 94
UPDATING RECORD
Sample Program
/* REXX */ ALLOCATE DSN(T13066.INPUT.DATA) DDN(INFILE) OLD REUSE EOF = NO CALL READIT DO WHILE EOF =NO PULL REC /* HERE CHANGE RECORD */ PUSH REC CALL WRITEIT CALL READIT END EXECIO 0 DISKW INFILE (FINIS) FREE DDDN(INFILE) REXX/WIPRO TECH program continues in the next slide... 95
READIT: EXECIO 1 DISKRU INFILE IF RC <> 0 THEN EOF = YES RETURN WRITEIT: EXECIO 1 DISKW INFILE RETURN
REXX/WIPRO TECH
96
SESSION EIGHT
HANDLE AID
DEBUGGING
What you will be able to do after this session ???
After the end of this session you will be able to use the tracing facilities that are available in rexx.
REXX/WIPRO TECH
97
Note:
Interactive debugger will be active for a single exec that is going to be executed after the executil ts. It will not be available for the next exec that is going to follow . If you want the debugger to be switched on for the next exec you have to issue one more executil ts.
REXX/WIPRO TECH 98
enter hi to end , a null line to continue, or an immediate command Then you can type put into the interactive debug by typing ts stop the exec and return to tso hi cancel the output of a say or a trace by typing ht stop all the tracing by typing te continue the program execution by pressing enter
REXX/WIPRO TECH 99