Rexx was developed by IBM in the late 1970s. Rexx or Restructured Extended Executor is a programming language that carries various characteristics such as functions, support for UNIX commands, file I/O operations, debugging, and crash security. This article describes the use of REXX for mainframe computers.
A function is a built-in or visible method that delivers a unique result string. In REXX, a subroutine is a function that can deliver a result and it is called with the CALL instruction. The following program is showing the use of IRRXUTIL package in the mainframe:
/* REXX */ /* Get user information and display what is available */ theVar = "rr" theProfile = 'NEWUSER' theClass = 'USER' irrRC = IRRXUTIL('EXTRACT',theClass,theProfile,theVar,"",'FALSE') say "Class: " rr.CLASS say "Profile: " rr.PROFILE say "Here are" rr.0 "segments" do s = 5 to rr.0 seg = rr.s say "Segment information:" seg do k = 1 to rr.seg.0 stem = rr.seg.k do i = 5 to rr.seg.stem.0 say seg ":" rr.seg.k ":" rr.seg.stem.i end end end exit
IRRXUTIL is a utility that can be used to convert the result of a R_admin service to get a request to a set of REXX stem variables. The stem variables are created to the given profile data in one of the methods like: by field name where the field name is recognized by the caller.Rexx programming in the mainframe does not ask users to explicitly declare variables.
For instance, the variable is specified as the integer-value 10. Therefore, say the number would present the value 10 on the Mainframe output Screen. If the variable text is specified the string ‘We are learning Rexx Programming language’ then say text would present ‘We are learning Rexx Programming language’ on the output screen.
One of the most important characteristics of Rexx is its capacity to parse text values. The following program is displaying the use of parse in the mainframe.
PARSE {UPPER|LOWER|caseless} source {src}
Example:
/* My Main program */ parse value 'I love Rexx Programs' with word1 word2 word3 word4 say "'"word1"'" say "'"word2"'" say "'"word3"'" say "'"word4"'"
The above program will give the following output in the phases:
A REXX loop enables users to fulfill a statement or various statements numerous times. The following example is the common practice of a loop statement in the mainframe computers. In the mainframe, the do loop is applied to fulfill a number of statements for a specific number of times. It can be achieved by using a parameter and a condition.
do index = start [limit] [increment] [for count] condition #1 Condition #2 end Example /* My First program */ do a = 0 to 7 by 2 say "hello world" end
There are five types of REXX instructions. These are
The following case is an ISPF/PDF Edit panel that displays an exec with different kinds of instructions. A summary of each kind of instruction issue after the case. In most of the reports, users will notice an edit line number.
EDIT —- USERID.REXX.EXEC ===> SCROLL ===> HALF ****** ************************ MAIN INFORMATION
************************************ 000001 /**************************
REXX ****************************/ 000002 /*
000005 Prog1:
000006
000007 SAY ‘How are you?’
000008 PULL userreply
000011 IF userreply = ‘ ‘ THEN
000012 SAY “O.K.”
000013 ELSE
000014 DO
000015 SAY “I’m fine:”
000016
000017 END
000018
000019 EXIT
****** *********************** END **********************************
A CLIST can request an exec with the EXEC command. It can request it explicitly or implicitly. If it requests it implicitly then the exec is in the PDS designated to SYSEXEC or SYSPROC. If it requests a CLIST implicitly then the CLIST is in a PDS allocated to SYSPROC.
When an exec requests a CLIST, the CLIST can give a number to the exec by using the EXIT CODE() argument with the output number inserted in brackets after CODE. The exec accepts the number in the REXX specific variable called RC.