Professional Documents
Culture Documents
Revision List
TABLE OF CONTENTS
1. REXX .............................................................................................................. 1
1.1 INTRODUCTION TO REXX............................................................................ 1
1.1.1 What is REXX ? ................................................................................ 1
1.1.2 Brief History Of REXX....................................................................... 1
1.2 GENERAL FORMAT OF REXX STATEMENTS ................................................. 4
1.3 CREATE AND EXECUTE A REXX PROGRAM ................................................. 6
1.4 OPERATORS .............................................................................................. 7
1.4.1 Arithmetic Operators......................................................................... 7
1.4.2 Concatenation Operators.................................................................. 7
1.4.3 Operator Precedence ....................................................................... 7
1.4.4 Logical Operators ............................................................................. 8
1.4.5 Comparison Operators ..................................................................... 8
2. FUNCTIONS, COMMANDS AND INSTRUCTIONS ..................................... 11
2.1 TERMINAL INPUT AND OUTPUT .................................................................. 11
2.2 CONDITIONAL INSTRUCTIONS ..................................................................... 14
2.3 LOOPING INSTRUCTIONS ........................................................................... 19
2.4 SUBROUTINES AND FUNCTIONS ................................................................. 25
2.5 BUILT-IN FUNCTIONS ................................................................................. 33
2.5.1 String Manipulating Functions ........................................................ 33
2.5.2 Arithmetic Functions ....................................................................... 41
2.5.3 Comparison Functions .................................................................... 43
2.5.4 Conversion functions ...................................................................... 45
2.5.5 Formatting Functions ...................................................................... 48
2.5.6 Miscellaneous Functions ................................................................ 51
2.6 TSO/E EXTERNAL FUNCTIONS .................................................................. 55
2.7 TSO/E REXX COMMANDS ....................................................................... 60
2.8 DEBUGGING EXECS ................................................................................ 68
2.8.1 Tracing Commands with the TRACE Instruction ............................ 68
2.8.2 Using REXX Special Variables RC and SIGL................................. 69
2.9 COMPOUND VARIABLES AND STEM........................................................... 71
2.10 SAMPLE REXX PROGRAM ........................................................................ 72
2.11 REXX CODING STANDARDS ...................................................................... 74
3. ISREDIT MACROS ....................................................................................... 75
3.1 ISPF/PDF MACRO COMMAND DESCRIPTIONS INDEX .................................. 77
3.2 ISPF/PDF EDIT MACRO COMMANDS ......................................................... 80
3.3 SAMPLE ISREDIT MACRO...................................................................... 99
4. ISPF SERVICES ......................................................................................... 100
4.1 ISPF SERVICES INDEX ........................................................................... 100
1. REXX
♦ Request input from the terminal and Display output on the terminal
♦ Execute TSO commands under program control
♦ Read and Write files
REXX is more modern, powerful language, and is the procedural language for
IBM’s System Application Architecture (SAA), which means REXX is implemented
across IBM’s product line.
EXEC 2 proved the concept of a general macro language. It was used mostly for
writing system commands and macros for wide variety of editors. Its interpreter
was provably, still is, fewest example of efficient robust system/370 assembler
code. However, EXEC2 (like its predecessor and most other macro languages of
1970 ‘s and even early 1980 s) assumed that macro programs would be mostly
commands with relatively little “glue” of logic and variables. Accordingly, it was
designed to allows commands ( literal strings, usually upper case) to be written
plainly, where as language keywords and variables were identified by prefix of an
ampersand.
1
This style, while adequate for simple commands, proved cumbersome for large
and complex programs and macros that were soon being written in EXEC 2. It
became clear that new language was needed, one based on classical syntax and
semantic used by languages in tradition of ALGOL, Pascal, and PL/I yet including
command and string programming facilities that EXEC 2 had proven to be so
effective and powerful. This new language initially called Rex (because the name
sounded nice) was very much driven by the desire to make programming easy. It
borrows most of its features from other languages, especially PL/I and EXEC 2,
but these features are modified or expressed in ways that make them easy to use
(but not necessary easy to implement!).
The first specification for the language is dated 29 March 1979. This was written
before any implementation was designed, and it was circulated to number of
people for comment: this began the tradition of documentation before
implementation the characterized development of REXX. Its name gained an “x”
to avoid any confusion with other products.
REXX was included the third release of IBM’s VM / System product shipped in
1983. It was soon discovered that IBM’s customers liked the language just as
much as did the “internal” users. Only 2 years later, the first non-IBM
implementation ( by the Mansfield Software Group, for PC-DOS ) became
available.
In 1987 IBM announced that REXX was to be the Procedures language for its
Systems Application Architecture (SAA), which was followed by implementations
for a number of operating systems including MVS/TSO, AS/400, and (in 1989),
the Extended Edition of OS/2 1.2. The first REXX compiler was developed at
IBM’s Vienna laboratory, following research by the IBM Haifa Scientific Center,
and was delivered to customers in 1989. By 1990 there was sufficient interest in
the language to justify the first international REXX Symposium for developers and
users, organised by the Stanford linear accelator center in California. This
symposium has been held annually since then.
Recent version of REXX from IBM include REXX for the AIX/6000 Operating
System, REXX for Netware, and REXX for CICS transaction Monitor. REXX is
now available for the most significant operating systems, and from several
vendors, not just IBM. Freeware or Shareware version, often excellent, are also
available for PC-DOS, UNIX, and other systems.
REXX is also a player in Java environment, too. A new dialect of REXX, called
Net REXX , works seamlessly within Java environment: Net REXX programs can
use any Java class; this Java security and performance to REXX programs , and
REXX arithmetic and simplicity to Java. A single language Net REXX, may be
used for scripting and application development.
2
REXX (Restructured Extended eXecutor)
IT ALLOWS YOU TO :
♦ DO FILE MANIPULATIONS
3
1.2 General Format Of REXX Statements
More than one statement can appear on one line, separated from each other with
semicolons. Also, one statement can span more than one line, in which case a
comma at the end of the line indicates a continuation of the statement.
Comments appear between the delimiters /* and */ and can span one or more
lines. Variables do not need to be predefined, and you can type instructions in
upper, lower, or mixed case. A comma is the continuation character and indicates
that the instruction continues to then next line. A semicolon indicates the end of
the instruction and is used to separate multiple instructions on one line.
4
Beginning an instruction
An instruction can begin in any column on any line. The following are all valid
instructions.
Continuing an instruction
A comma indicates that the instruction continues to the next line. Note that a
space is added between "extended" and "REXX" when it appears on the screen.
If you need to continue an instruction to a second or more lines but do not want
REXX to add spaces when the line appears on the screen, use the concatenation
operand (||).
Results
Ending an instruction:
If you put more than one instruction on a line, you must separate each instruction
with a semicolon.
SAY 'Hi!'; say 'Hi again!'; say 'Hi for the last time!'
5
1.3 Create And Execute A REXX Program
Before you can write a REXX program, called an exec, you need to create a data
set to contain the exec. The data set can be either sequential or partitioned, but if
you plan to create more than one exec, it is easier to create a REXX library as a
partitioned data set (PDS) with execs as members. You can allocate the PDS with
the Utilities option in ISPF/PDF or with the TSO/E ALLOCATE command. It is
recommended that allocate a data set with your prefix as the first qualifier, any
name as the second qualifier, and preferably "exec" as the third qualifier.
Note that this simple exec starts with a comment line to identify the program as a
REXX exec. A comment begins with /* and ends with */. This program displays
the line
After you have placed REXX instructions in a data set, you can run the exec
explicitly by using the EXEC command followed by the data set name or implicitly
by entering the member name. You can run an exec implicitly only if the PDS that
contains the exec was allocated to a system file (SYSEXEC OR SYSPROC) or it
is allocated to an application CLIST OR EXEC.
Explicit execution
=è TSO EX ‘CCI.TST.EXEC(compile)’
Implicit Execution
=èTSO compile
Implicit execution can be done only if the PDS containing the REXX program is
allocated to system files ( SYSEXEC or SYSPROC ) using the tso alloc command
or the the PDS is allocated to a application CLIST or EXEC using TSO ALTLIB
command.
6
1.4 Operators
Operator Operation
+ Addition
- Subtraction
* Multiplication
/ Division, returning decimal quotient
% Division, returning integer
quotient
// Division, returning remainder
** Exponential
-n Negation
+n Addition
Operator Operation
blank Concatenate two strings with a blank character
in between.
!! Concatenate two strings without a blank character in between.
7
1.4.4 Logical Operators
A comparison operator is used when two operands are compared with each
other. After a comparison expression is processed, from left to right, it yields 1 if
the comparison condition is true and 0 if the comparison condition is false. The
following is a list of REXX comparison operators.
Operator Operation
== Strictly equal
= Equal
\== Not strictly equal
\= Not equal
> Greater than
< Less than
>< Greater than or less than
>= Greater than or equal to
<= Less than or equal to
\< Not less than
\> Not greater than
>>= Strictly greater than or equal to
<<= Strictly less than or equal to
<> Less or greater than
>> strictly greater than
<< Strictly less than
8
OPERATORS
♦ ARITHMETIC OPERATORS
♦ CONCATENATION OPERATORS
♦ LOGICAL OPERATORS
♦ COMPARISON OPERATORS
FOR COMPARISONS
E.G.:- = FOR EQUAL TO
> FOR GREATER THAN
9
Variable Names
E.g.;-
MYSTRING = “THIS IS THE CONTENT OF MYSTRING”
NUMBER1 = 10
NUMBER2 = 20
NUMBER3 = NUMBER1 + NUMBER2
10
2. Functions, Commands And Instructions
♦ Numeric Functions
E.g.:- Max, Min, BITXOR
Terminal instructions Say and Put is used display output and receive input from
the terminal.
11
TERMINAL INPUT AND OUTPUT
EXAMPLE
12
Pull And Say - Terminal Input And Output
SAY Instruction
♦ General Format
SAY expression
♦ Description
♦ Example
PULL Instruction
♦ General format
PULL template
♦ Description
The pull instruction reads the top element of a data stack and uses it as source
data. If the data stack is empty, then PULL will read from the terminal. The
PULL instruction is the same as REXX instruction PARSE UPPER PULL
[template].
Template consists of alternating patterns and variable names.
♦ Example
13
2.2 Conditional Instructions
There are two types of conditional instructions. IF/THEN/ELSE can direct the
execution of an exec to one of two choices. SELECT/WHEN/OTHERWISE/END
can direct the execution to one of many choices.
14
IF/THEN/ELSE INSTRUCTIONS
IF logical-expression THEN
statement
ELSE
statement
OR
IF logical-expression THEN
DO
statement1
statement 2
…………….
END
ELSE
DO
statement1
statement 2
………….
…………
END
EXAMPLE
IF I=100 THEN
SAY ‘VALUE OF I IS 100’
ELSE
SAY ‘VALUE OF I NOT EQUAL TO 100’
15
IF/THEN/ELSE Instructions
The IF instruction executes one or many REXX statements based on the result of
evaluating an expression.
If the ELSE clause appears on the same line as the last portion of the THEN
statement set, a semicolon is needed to tell REXX to terminate the THEN
statement set
Nested Ifs must have an ELSE clause paired with the THEN clause. If no action is
appropriate for the ELSE clause, you can use the 'NOP' (no operation) statement
as the statement after the ELSE. ( Example 3 )
Example
2. if reply = ‘YES' then say '10-4'; else say 'Please try again:'
Not matching nested Ifs to Else’s and DOs to ENDs can have some surprising
results.
16
SELECT Instruction- Conditional Execution of statement
SELECT
[OTHERWISE statements]]
END;
SELECT
WHEN Y = 0 THEN SAY ‘Y IS 0’
WHEN Y = 1 THEN SAY ‘Y IS 1’
WHEN Y = 2 THEN SAY ‘Y IS 2’
OTHERWISE SAY ‘Y< 0 OR > 2’
END
17
Using the SELECT/WHEN/OTHERWISE/END Instruction
Example
"Thirty days hath September, April, June, and November; all the rest have thirty-
one, save February alone ..."
Write an exec that provides the number of days in a month. First have the exec
ask the user for a month specified as a number between 1 and 12 (with January
being 1, February 2, and so forth). Then have the exec reply with the number of
days. For month "2", the reply can be "28 or 29".
/******************************** REXX*****************************/
/* This exec requests the user to enter a month as a whole number */
/* from 1 to 12 and responds with the number of days in that */
/* month */
/******************************************************************/
SELECT
WHEN month = 9 THEN
days = 30
WHEN month = 4 THEN
days = 30
WHEN month = 6 THEN
days = 30
WHEN month = 11 THEN
days = 30
WHEN month = 2 THEN
days = '28 or 29'
OTHERWISE
days = 31
END
SAY 'There are' days 'days in Month' month '.'
18
2.3 Looping Instructions
There are two types of looping instructions, repetitive loops and conditional loops.
Repetitive loops allow you to repeat instructions a certain number of times, and
conditional loops use a condition to control repeating. All loops, regardless of the
type, begin with the DO keyword and end with the END keyword. You can
combine repetitive and conditional loops to create a compound loop. There are
two types of conditional loops, DO WHILE and DO UNTIL. Both types of loops
are controlled by one or more expressions. However, DO WHILE loops test the
expression before the loop executes the first time and repeat only when the
expression is true. DO UNTIL loops test the expression after the loop executes at
least once and repeat only when the expression is false. The LEAVE instruction
causes an immediate exit from a repetitive loop. Another instruction, ITERATE,
stops execution from within the loop and passes control to the DO instruction at
the top of the loop.
19
DO INSTRUCTION
END
20
SIMPLE DO:
DO
statement 1
……
....
END
Controlled Repetitive DO :
DO-FOR loop
END;
The FOR clause specifies a non-negative whole number that sets a second limit
on the number of passes through the loop if no other condition terminates the
loop
DO-WHILE loop
21
1. DO 7 /* Repeats 7 times */
statement 1
statement 2
.….
END
2.
Do I = 2 to -1 by -1 /* Would display:*/
say I /* 2 on 1st pass through loop */
End /* 1 on 2nd pass through loop */
6 DO FOREVER
say ‘execute this loop forever’
END
7. The following loop is set to repeat 10 times while a certain condition is met, at
which point it stops.
quantity = 20
DO number = 1 TO 10 WHILE quantity < 50
quantity = quantity + number
SAY 'Quantity = 'quantity ' (Loop 'number')'
END
22
LEAVE Instruction-Terminate a DO loop
LEAVE [name]];
Example
DO j = 1 t0 4
if j= 2 THEN LEAVE
SAY J /* Display 1 only */
END
23
ITERATE INSTRUCTION- END CURRENT ITERATION OF
DO LOOP
ITERATE [name]]
DO count = 1 TO 10
IF count = 8 THEN
ITERATE
ELSE
SAY 'Number' count /*List of numbers 1 t0 10
exception of number 8*/
END
24
2.4 Subroutines and Functions
25
Subroutines and Functions
CALLING A SUBROUTINE
CALLING A FUNCTION
x = function(argument1, argument2,...)
RETURN value
x = function(argument1, argument2,...)
26
Passing Information by Using Variables
When an exec and its internal function 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 function.
Example
/*REXX*******/
number1 = 5
number2 = 10
SAY add()
SAY answer
EXIT
add:
answer = number1 + number2
RETURN answer
Using the same variables in an exec and its internal function can sometimes
create problems.
To avoid this kind of problem in an internal function, you can use: The
PROCEDURE instruction.
Using the ARG Instruction: The function can receive the arguments with the ARG
instruction. Arguments are also separated by commas in the ARG instruction.
ARG arg1,arg2,arg3 .......
27
PROCEDURE INSTRUCTION-DEFINE A PROCEDURE
Example
28
ARG instruction
ARG template
Example
29
CALL Instruction
Example
Y = 2
CALL SQUARE Y /* CALL THE ROUTINE TO CALCULATE
SQUARE OF Y */
SAY ‘SQUARE OF ‘Y’ IS ‘ RESULT
……
……
SQUARE: PROCEDURE
ARG N
RETURN N*N
30
EXIT INSTRUCTION-TERMINATE EXEC
EXIT [expression]];
Example
X=4
EXIT x*3 /* terminate exec */
31
Examples
The following program calls the function greatest which returns the max of three
numbers. First time it is called as a subroutine and then it is called as a function.
/*REXX*/
A= 1
B = 4
C = 5
MAX = 0
CALL GREATEST A B C /* SUBROUTINE CALL*/
SAY 'EXPOSED VARIABLE MAX' MAX
SAY 'RETURNED VALUE RESELT' RESULT
SAY ‘GREATEST(A B C) ‘ GREATEST(A B C) /* FUNCTION CALL */
EXIT
/*******************************************/
/*Function :greatest */
/*Arguments :N1 N2 N3 */
/*Returns greatest among N1,N2 and N3 */
/******************************************/
Recursive routines
/*REXX*/
N= 10
DO I = 0 TO N
SAY B(N I)/* Binomial coefficients */
END
EXIT
B:PROCEDURE
ARG N R
SELECT
WHEN R = 1 THEN RETURN(N)
WHEN (R = N ! N = 1! R = 0 ) THEN RETURN(1)
WHEN N = 0 THEN SAY 'ERROR! NOT DEFINED!'
OTHERWISE
RETURN(B(N-1 R) + B(N-1 R-1))
END
32
2.5 Built-in Functions
Over 50 functions are built into the language processor. The built-in functions fall
into the following categories: Arithmetic functions, Comparison functions,
Conversion functions, Formatting functions, String manipulating functions,
Miscellaneous functions.
33
Following is the list of all string manipulating functions. Commonly used functions
are explained later.
Function Description
ABBREV Returns a string indicating if one string is equal to the specified
number of leading characters of another string.
DELSTR Returns a string after deleting a specified number of
characters, starting at a specified point in the input string.
DELWORD Returns a string after deleting a specified number of words,
starting at a specified word in the input string.
FIND * Returns the word number of the first word of a specified phrase
found within the input string.
INDEX * Returns the character position of the first character of a
specified string found in the input string.
INSERT Returns a character string after inserting one input string into
another string after a specified character position.
LASTPOS Returns the starting character position of the last occurrence of
one string in another.
LENGTH Returns the length of the input string.
OVERLAY Returns a string that is the target string overlaid by a second
input string.
POS Returns the character position of one string in another.
REVERSE Returns a character string, the characters of which are in
reverse order (swapped end for end).
STRIP Returns a character string after removing leading or trailing
characters or both from the input string.
SUBSTR Returns a portion of the input string beginning at a specified
character position.
SUBWORD Returns a portion of the input string starting at a specified word
number.
TRANSLATE Returns a character string with each character of the input
string translated to another character or unchanged.
VERIFY Returns a number indicating whether an input string is
composed only of characters from another input string or
returns the character position of the first unmatched character.
WORD Returns a word from an input string as indicated by a specified
number.
WORDINDEX Returns the character position in an input string of the first
character in the specified word.
WORDLENGTH Returns the length of a specified word in the input string.
WORDPOS Returns the word number of the first word of a specified phrase
in the input string.
WORDS Returns the number of words in the input string.
* Indicates a non-SAA built-in function provided only by TSO/E.
34
FIND FUNCTION
♦ DESCRIPTION
♦ RETURN
THE FUNCTION RETURNS THE FIRST POSITION OF THE
PHRASE IF IT IS FOUND, OTHERWISE IT RETURNS 0.
♦ EXAMPLE
35
INDEX function-Search for substring
INDEX(string, substring[[,startposition]] )
EXAMPLE
36
INSERT FUNCTION-INSERT A STRING
INSERT(ins-string, string[[,[[n]][,[[length]][,pad]]]] )
37
LENGTH function-Get the length of a string
LENGTH(string)
♦ Description
♦ Example
LENGTH(“All dogs go to heaven”) returns 21.
38
STRIP function-Remove leading/trailing characters
♦ Description
The STRIP function removes any leading and trailing characters
from a string.
string is the data from which characters are removed.
Both means to remove both leading and trailing characters from
string.
Leading/Trailing means to remove leading/trailing characters
from string.
‘char’ is the character to be removed from string; the default is a
blank.
♦ Return
The function returns the stripped string.
♦ Example
39
SUBSTR function-Extract a substring
SUBSTR(string, position[[,[[length]][,pad]]])
♦ Description
40
2.5.2 Arithmetic Functions
These functions evaluate numbers from the argument and return a particular
value.
Function Description
ABS Returns the absolute value of the input number.
DIGITS Returns the current setting of NUMERIC DIGITS.
FORM Returns the current setting of NUMERIC FORM.
FUZZ Returns the current setting of NUMERIC FUZZ.
MAX Returns the largest number from the list specified, formatted
according to the current NUMERIC settings.
MIN Returns the smallest number from the list specified, formatted
according to the current NUMERIC settings.
RANDOM Returns a quasi-random, non-negative whole number in the range
specified.
SIGN Returns a number that indicates the sign of the input number.
TRUNC Returns the integer part of the input number, and optionally a
specified number of decimal places.
41
MAX function-Determine the maximum value
MAX(number,....)
♦ Description
42
2.5.3 Comparison Functions
Function Description
COMPARE Returns 0 if the two input strings are identical. Otherwise, returns
the position of the first character that does not match.
DATATYPE Returns a string indicating the input string is a particular data
type, such as a number or character.
SYMBOL Returns this state of the symbol (variable, literal, or bad).
43
COMPARE function
COMPARE(string1,string2[[,pad]])
♦ Description
♦ Example
44
2.5.4 Conversion functions
These functions convert one type of data representation to another type of data
representation.
45
Data Conversion functions
Function Description
B2X Returns a string, in character format, that represents the input binary
string converted to hexadecimal. (Binary to hexadecimal)
C2D Returns the decimal value of the binary representation of the input
string. (Character to Decimal)
C2X Returns a string, in character format, that represents the input string
converted to hexadecimal. (Character to Hexadecimal)
D2C Returns a string, in character format, that represents the input decimal
number converted to binary. (Decimal to Character)
D2X Returns a string, in character format, that represents the input decimal
number converted to hexadecimal. (Decimal to Hexadecimal)
X2B Returns a string, in character format, that represents the input
hexadecimal string converted to binary. (Hexadecimal to binary)
X2D Returns the decimal representation of the input hexadecimal string.
(Hexadecimal to Decimal)
46
X2C function-Convert hexadecimal to character
X2C(hex-string)
♦ Description
The X2C function converts a string of hexadecimal values into a
character string.
Hex-string is one or more hexadecimal digits to be converted.
♦ Return
The function returns the converted character string.
♦ Example
X2C(‘F0F1F2’) returns 012.
47
2.5.5 Formatting Functions
These functions manipulate the characters and spacing in strings supplied in the
argument.
Function Description
CENTER/ Returns a string of a specified length with the input string
CENTRE centered in it, with pad characters added as necessary to
make up the length.
COPIES Returns the specified number of concatenated copies of the
input string.
FORMAT Returns the input number, rounded and formatted.
JUSTIFY * Returns a specified string formatted by adding pad
characters between words to justify to both margins.
LEFT Returns a string of the specified length, truncated or padded
on the right as needed.
RIGHT Returns a string of the specified length, truncated or padded
on the left as needed.
SPACE Returns the words in the input string with a specified
number of pad characters between each word.
48
SPACE
SPACE(string[[,n]][,pad]])
Examples
49
JUSTIFY
JUSTIFY(string, length,[[pad]])
Examples
50
2.5.6 Miscellaneous Functions
These functions do not clearly fit into any of the other categories.
51
Miscellaneous Functions
Function Description
ADDRESS Returns the name of the environment to which commands are
currently being sent.
ARG Returns an argument string or information about the argument
strings to a program or internal routine.
BITAND Returns a string composed of the two input strings logically
ANDed together, bit by bit.
BITOR Returns a string composed of the two input strings logically
ORed together, bit by bit.
BITXOR Returns a string composed of the two input strings exclusive
ORed together, bit by bit.
CONDITION Returns the condition information, such as name and status,
associated with the current trapped condition.
DATE Returns the date in the default format (dd mmm yyyy) or in one
of various optional formats.
ERRORTEXT Returns the error message associated with the specified error
number.
EXTERNALS* Returns the number of elements in the terminal input buffer. In
TSO/E, this function always returns a 0.
LINESIZE* Returns the current terminal line width minus 1.
QUEUED Returns the number of lines remaining in the external data
queue at the time when the function is invoked.
SOURCELINE Returns either the line number of the last line in the source file or
the source line specified by a number.
TIME Returns the local time in the default 24-hour clock format
(hh:mm:ss) or in one of various optional formats.
TRACE Returns the trace actions currently in effect.
USERID* Returns the TSO/E user ID, if the REXX exec is running in the
TSO/E address space.
VALUE Returns the value of a specified symbol and optionally assigns it
a new value.
XRANGE Returns a string of all 1-byte codes (in ascending order) between
and including specified starting and ending values.
52
ADDRESS instruction
♦ Description
EXAMPLE
53
ADRESS INSTRUCTION
General format
Expression is first evaluated by REXX; the result is sent to the host environment
as a command to be executed. IF expression is not specified then the destination
is set permanently until the next ADDRESS instruction is issued. Subsequent
non-EXEC commands will be sent to this new host environment. If expression is
specified, then the host environment is effective during the execution of this
ADDRESS instruction.
Return
The return code from the host environment, after the command is executed, is
placed in the special variable RC.
Example
/*REXX*/
SAY 'DO YOU KNOW YOUR PF KEYS?'
PULL ANSWER
IF ANSWER = 'NO' ! ANSWER = 'N' THEN
ADDRESS ISPEXEC "DISPLAY PANEL(ISPOPT3C)"
/*Address ISPEXEC to issue to ISPF service*/
ELSE
SAY 'O.K. NEVER MIND.'
54
2.6 TSO/E External Functions
In addition to the built-in functions, TSO/E provides external functions that you
can use to do specific tasks. Some of these functions perform the same services
as control variables in the CLIST language.
55
The TSO/E external functions
LISTDSI - returns in variables the data set attributes of a specified data set. The
function call is replaced by a function code that indicates whether or not the call
was successful.
MSG - controls the display of TSO/E messages. The function returns the previous
setting of MSG.
PROMPT - sets the prompt option on or off for TSO/E interactive commands. The
function returns the previous setting of prompt.
SYSCPUS - returns in a stem variable information about all CPUs that are online.
SYSVAR - uses specific argument values to return information about the user,
terminal, language, exec, system, and console session.
56
OUTTRAP FUNCTION
X = OUTTRAP(‘Var’)
X = OUTTRAP(‘Var’,5)
X = OUTTRAP(‘OFF’)
57
Examples
x = OUTTRAP('var',5)
This results in up to 5 lines of command output stored in var1, var2, var3, var4,
var5; and var0 contains the number 5.
The stem variable includes a period, which causes the lines of output to be stored
in a series of compound variables.
x = OUTTRAP('var.')
"LISTC"
SAY 'The number of lines trapped is' var.0
lines = var.0 + 1
"LISTDS mynew.exec MEMBERS"
SAY 'The number of lines trapped is' var.0
DO I = lines TO var.0
SAY var.i
END
To turn trapping off, reissue the OUTTRAP function with the word "OFF"
58
SYSDSN function-Check dataset status
SYSDSN(dsname or ‘dsname(member)’)
59
2.7 TSO/E REXX Commands
60
Using REXX commands
An exec can consist of nothing but TSO/E commands, such as an exec that sets
up a user's terminal environment by allocating the appropriate libraries of data
sets, or the exec can contain commands intermixed with REXX language
instructions.
When an exec issues a command, the REXX special variable RC is set to the
return code. An exec can use the return code to determine a course of action
within the exec. Every time a command is issued, RC is set. Thus RC contains
the return code from the most recently issued command.
Many TSO/E commands use single quotation marks within the command. For
example, ALLOCATE, require single quotation marks around fully-qualified data
set names.
Executing EXEC : To explicitly invoke another exec from within an exec, issue
the EXEC command as you would any other TSO/E command.
"EXEC myREXX.exec(calc) '24 55 12 38' "
You might want to invoke an exec with the EXEC command rather than as an
external routine when the exec is not within the same PDS as the calling exec, or
when the PDSs of the two execs are not allocated to either SYSEXEC or
SYSPROC.
61
Stacks and Related commands
NEWSTACK and DELSTACK command
NEWSTACK
Example
“NEWSTACK”
The DELSTACK command removes the data stack and deletes all
elements from it.
Example
“DELSTACK” /*removes stack */
62
PUSH instruction- Put an element at the top of the data
stack
PUSH expression
♦ Description
The PUSH instruction places a new element at the top of the data
stack.
expression is the element to be placed in the data stack.
♦ Example
line = “WallyMagoo”
PUSH line /* place line at the top of the stack */
63
PULL instruction- Get an element from the top of the data
stack
PULL template
♦ Description
THE PULL INSTRUCTION READS THE TOP ELEMENT OF DATA
STACK AND USES IT AS SOURCE DATA. IF THE DATA STACK IS
EMPTY, THEN PULL WILL READ FROM THE TERMINAL. THE
PULL INSTRUCTION IS THE SAME AS THE REXX INSTRUCTION
PARSE UPPER PULL
template CONSISTS OF ALTERNATING PATTERNS AND
VARIABLE NAMES.
♦ EXAMPLE
SAY ‘PLEASE ENTER YOUR FIRST NAME: ‘
PULL NAME.
64
EXECIO command-Read and write data
Read Operation
Write operation
65
EXECIO command-Read and write data
Example
1. To open a data set without reading any records, put a zero immediately
following the EXECIO command and specify the OPEN operand.
2. To read a specific number of lines, put the number immediately following the
EXECIO command.
"EXECIO 25 ..."
3. To read the entire data set, put an asterisk immediately following the EXECIO
command.
5. To read just 5 lines to the data stack starting at line 100, write the following:
6. To open a data set at line 100 without reading lines to the data stack, write the
following:
66
EXECIO Example
EXIT 0
67
2.8 Debugging EXECS
The TRACE instruction has many options for various types of tracing, two of
which are "commands" or "c" and "error" or "e".
TRACE C: When you specify "trace c" in an exec, any command that follows is
traced before it is executed, then it is executed, and the return code from the
command is displayed.
E.g.:- Trace ? C
?- is the prefix which means enables interactive tracing
If an exec includes "trace c" and again incorrectly issues a command, the exec
displays the line number and the command, executes it, and displays the error
message and the return code from the command
TRACE E: When you specify "trace e" in an exec, any host command that results
in a nonzero return code is traced after it executes and the return code from the
command is displayed.
68
2.8.2 Using REXX Special Variables RC and SIGL
RC: RC stands for return code and is set every time a command is issued. When
a command ends without error, RC is usually set to 0. When a command ends in
error, RC is set to whatever return code is assigned to that error.
The value of RC is set by every command and might not remain the same for the
duration of an exec. When using RC, make sure it contains the return code of the
command you want to test.
SIGL: The SIGL special variable is used in connection with a transfer of control
within an exec because of a function, or a SIGNAL or CALL instruction. When the
language processor transfers control to another routine or another part of the
exec, it sets the SIGL special variable to the line number from which the transfer
occurred.
SIGL and the SIGNAL ON ERROR instruction can help determine what command
caused an error and what the error was. When SIGNAL ON ERROR is included
in an exec, any host command that returns a nonzero return code causes a
transfer of control to a routine named "error".
Example
/* REXX */
SIGNAL ON ERROR
"ALLOC DA(new.data) LIKE(old.data)"
…
…
"LISTDS ?"
…
…
EXIT
ERROR:
SAY 'The return code from the command on line' SIGL 'is' RC
69
Debugging EXECs
70
2.9 Compound Variables And STEM
FRED.5
Array.Row.Col
employee.name.phone
You can use a DO loop to initialize a group of compound variables and set up an
array.
DO i = 1 TO 6
you can alter all the compound variables in an array through the stem. you can
alter all the compound variables in an array through the stem.assignment
instruction:
employee. = 'Nobody'
You can use stems with the EXECIO command when reading to and writing from
a data set. You can also use stems with the OUTTRAP external function when
trapping command output:
71
2.10 Sample REXX Program
/*REXX*/
/* THIS PROGRAM ENCRPYTS/DECRYPTS A DATA SET*/
/* USAGE : TSTMAC CODE DDNAME1 DDNAME2 KEY*/
PARSE ARG CODE DDNAME1 DDNAME2 KEY
ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '
SUB = 'ZYXWABCDVU TSRQPONMLKJIHGFE'
/* FOR ENCRYPTION THIS MACRO REPLACES THE CHARACTER WITH THE */
/*CORRESPONDING CHARACTER IN SUB */
ADDRESS TSO
"ALLOC F(IN) DA('"DDNAME1"') SHR"
"ALLOC F(OUT) DA('"DDNAME2"') SHR"
'EXECIO * DISKRU IN ( FINIS STEM Q'
FIRST_CHARACTER = 1
IF RC > 0 THENDO
SAY 'ERROR IN ALLOCATE FILE .EXITING ..'
EXIT
END
DO LINE = 1 TO Q.0 /*FOR EACH LINE*/
LINE_LENGTH = LENGTH(Q.LINE)
DO CHARACTER=1 TO LINE_LENGTH/*FOR EACH CHARACTER*/
CH = SUBSTR(Q.LINE,CHARACTER,1)
IF KEY = '' THEN/* IF KEY IS NOT SPECIFIED */
CH = GET_SUB(CODE,CH) /*ENCRYPTION BY SUBSTITUTION*/
ELSE
CH = BITXOR(CH,KEY)/* ENCRYPTION BY XOR BETWEEN CH AND*/
/*KEY*/
IF CHARACTER = FIRST_CHARACTER THEN
P.LINE = CH
ELSE
P.LINE = P.LINE!!CH
END
END
'EXECIO * DISKW OUT ( FINIS STEM P'
"FREE F(IN)"
"FREE F(OUT)"
EXIT
72
/*THIS PROCEDURE RETURNS THE REPLACEMENT CHARACTER*/
GET_SUB : PROCEDURE EXPOSE SUB ALPHABET
ARG CODE1,CH1
DO I = 1 TO 27
IF CODE1 = 'E' THEN
IF SUBSTR(ALPHABET,I,1) = CH1 THEN
RETURN SUBSTR(SUB,I,1)
ELSE
NOP
ELSE
IF SUBSTR(SUB,I,1) = CH1 THEN
RETURN SUBSTR(ALPHABET,I,1)
ELSE
NOP
END
RETURN CH1
73
2.11 REXX Coding Standards
74
3. ISREDIT MACROS
You can use edit macros, which look like ordinary editor commands, to extend
and customize the editor. You create an edit macro by placing a series of
commands into a data set or member of a partitioned data set. Then you can run
those commands as a single macro by typing the defined name in the
commandline.
75
EDIT MACROS
76
3.1 ISPF/PDF Macro Command Descriptions Index
77
MACRO TYPE DESCRIPTION
LABEL c/a set or obtain a line label
LEFT c scroll display data to the left
LEVEL c/a set or obtain library member modification level
LINE a set or obtain line data values
LINE_AFTER a add a specific-data line after indicated line
LINE_BEFORE a add a specific-data line before indicated line
LINENUM a obtain current line number of a given label
LOCATE c locate a specific data line
LRECL a obtain the logical record length
MACRO c identify a command as a macro
MACRO_LEVEL a obtain current macro nesting level
MASKLINE a set or obtain mask line value
MEMBER a obtain the current member name
MEND c end a batch macro in MVS/370 environment
MODEL c copy a development model into the current
data
MOVE c move a library member into the current data
NONUMBER c turn off number mode of the current data
NOTES c/a set or obtain the current note mode
NULLS c/a set or obtain the current nulls mode
NUMBER c/a set or obtain the current number mode
PACK c/a set or obtain the current pack mode
PROCESS c process input line commands and changes
PROFILE c/a define, switch, lock, unlock and display edit
profile
RANGE_CMD a identify an entered key command
RCHANGE c repeatedly process the most recent CHANGE
request
RECFM a obtain the current data record format
RECOVERY c/a set or obtain the edit recovery mode
RENUM c turn on number mode and renumber all data
lines
REPLACE c replace a data set member
RESET c reset the line command area
RFIND c repeat a find of a search string
RIGHT c scroll the data to the right
RMACRO c/a set or obtain current recovery macro name
SAVE c save the current data into a data set
SCAN c/a set or obtain the current scan mode setting
SEEK c seek a data string and place cursor on that
line
SEEK_COUNTS a obtain counts from last SEEK command
SHIFT ( c shift all columns to the left
SHIFT ) c shift all columns to the right
SHIFT < c shift program statements to the left
SHIFT > c shift program statements to the right
SORT c sort data into a indicated order
STATS c/a set or obtain PDS member statistics
SUBMIT c submit data to run as a batch job
78
MACRO TYPE DESCRIPTION
TABS c/a set or obtain the tabs mode and define tab
character
TABSLINE a set or obtain the tabs line
TENTER c set text entry mode for multi-line "power
typing"
TFLOW c text flow a paragraph to restructure
fragmented pieces
TSPLIT c text split a line, moving some data to the next
line
UNNUMBER c remove sequence numbers and set number
mode off
UP c scroll up through the data a specified amount
USER_STATE a save and restore the user status of the edit
display
VERSION c/a set or obtain the ISPF library member version
number
XSTATUS a set or obtain a lines exclude status
79
3.2 ISPF/PDF Edit Macro Commands
Commonly used edit macros commands like Bound, change, Cursor, Edit are
described in this sections.
80
BOUNDS ISPF/PDF Edit Macro Command
ISREDIT BOUNDS lcol rcol
The 'lcol' parameter is the left boundary column value, which will
be set. The 'rcol' parameter is the right boundary column value to
be set. The 'lvar' and 'rvar' parameters are the names of the
variables that will receive the current left and right boundaries
respectively.
81
The BOUNDS macro allows for the setting of the left and right boundaries and
saving them in the edit profile. The assignment statement form of the BOUNDS
macro provides the current boundaries values in variables.
If both the BOUNDS macro command and the BOUNDS line command are used
at the same time, then the BOUNDS line command will override the macro
command.
ISREDIT BOUNDS
Example #2 - set the right boundary to column 72, while leaving the left
boundary alone by specifying an asterisk("*"):
ISREDIT BOUNDS * 72
Example #3 - obtain the current left boundary and put into variable &L:
82
The CANCEL ISPF/PDF Edit Macro Command
ISREDIT CANCEL
ISREDIT CANCEL
83
The FIND ISPF/PDF Edit Macro Command
ISREDIT FIND str {col1 {col2 } }
{label1 label2}
{NEXT } {ALL } {FIRST} {LAST } {PREV}
{CHARS } {PREFIX} {SUFFIX} {WORD }
{X} {NX}
84
String to be searched is any one of the following
Simple string - Not case sensitive
Hex string - eg. X’c27B’
Character string - Case sensitive (start with ‘c’) eg. C’Don’
Picture string - starts with ‘p’ eg. P’
Example#7 : Find all strings matching the pattern ‘-anteil-‘ followed by 2 digit
number.
85
The EXCLUDE ISPF/PDF Edit Macro Command
The EXCLUDE command may be used with the FIND or CHANGE commands
to locate a string, change the string, and then exclude that line from the
display.
86
Examples:
Example #3- exclude the first preceding line within labels .A and .C with a word
equal to THEN in columns 1 through 5:
87
The XSTATUS ISPF/PDF Edit Macro Command
88
CHANGE ISPF/PDF Edit Macro Command
89
CHANGE ISPF/PDF Edit Macro Command
Example #1:
ISREDIT CHANGE ME YOU
This example, the next occurrence of ME is changed to YOU. The letters ME can
be upper, lower or mixed case letters, and may be located anywhere within a
word, on any line
Example #2:
90
The DELETE ISPF/PDF Edit Macro Command
91
Example #1 - delete all non-excluded lines:
ISREDIT DELETE ALL NX
Example #2 - delete the lines between labels .HERE and .THERE that have a
blank in column 1:
ISREDIT DELETE 1 15
92
CHANGE_COUNTS ISPF/PDF Edit Macro Command
The 'var1' and 'var2' parameters are names of variables that will
receive the 8- character number of the strings, left-padded with
zeros, that were changed and that could not be changed,
respectively.
93
The CURSOR ISPF/PDF Edit Macro Command
94
The following are examples of the CURSOR assignment statement:
Example #1 - obtain the current cursor position line number into the variable
&WHERE:
ISREDIT CURSOR = 1 1
Example #3 - set the cursor to column 1 of the last data line:
Example #4 - set the cursor position to the line at label .LBL, without changing the
column position:
95
The LABEL ISPF/PDF Edit Macro Command
96
Examples
This isredit macro command puts the label .point on the current cursor position.
97
The END ISPF/PDF Edit Macro Command
ISREDIT END
98
3.3 Sample ISREDIT MACRO
Then following edit macro comments out all lines in a section of COBOL program,
section name is passed as a parameter. The edit macro can be invoked from
ISPF editor as
“COMMENT 1000-initialize”
here comment is the name of the edit macro and 1000-initialize is the section to
be commented.
/*REXX*/
"ISREDIT MACRO (PARM1)"
"ISREDIT F 8 ALL" PARM1/* find the section name at the 8th
column*/
CALL ERR_ROUTINE
"ISREDIT LABEL .ZCSR = .A" /*put the label on the first line
of the section */
CALL ERR_ROUTINE
"ISREDIT (X Y) = CURSOR"
CALL ERR_ROUTINE
X = X + 1
"ISREDIT CURSOR = (X) (Y)"
CALL ERR_ROUTINE
"ISREDIT FIND SECTION NEXT"
IF RC = 4 THEN /*IF IT IS THE LAST SECTION*/
DO
"ISREDIT CHANGE ALL ' ' '*' 7 .A .ZLAST"
EXIT
END
ISREDIT (X Y) = CURSOR"
CALL ERR_ROUTINE
X = X - 1
"ISREDIT CURSOR = (X) (Y)"
CALL ERR_ROUTINE
"ISREDIT LABEL .ZCSR = .B"/* put label on the last line of
the section */
CALL ERR_ROUTINE
"ISREDIT CHANGE ALL ' ' '*' 7 .A .B"
CALL ERR_ROUTINE
"ISREDIT SAVE"
CALL ERR_ROUTINE
EXIT
ERR_ROUTINE: PROCEDURE EXPOSE RC
IF RC > 0 THEN DO
SAY "MACRO ERROR!"
"ISREDIT CANCEL"/* Undo the changes */
EXIT
END
This edit macro can also be called from a REXX program using an ISPXEC EDIT
command.
99
4. ISPF SERVICES
All the ISPF services are listed below. Commonly used ISPF services are
described in the next section. Detailed information about all the ISPF services are
obtained from MVS/QuickRef ( product - ISPF SERVICES ).
Service Description
ADDPOP Begins pop-up window mode for panels
BRIF Browse interface from dialog program w/ flexible data capability
BROWSE Direct access to Browse from dialog
CONTROL Set environment options for display and error processing
EDIF Provide a dialog interface to the Edit service
EDIREC Provides recovery for the Edit interface facility
EDIT Allows direct access to the Edit service
EDREC Provides recovery for Edit service
DISPLAY Performs a panel display
FTCLOSE Ends file tailoring process and disposes of output file
FTERASE Erases a file tailoring output library member
FTINCL Initiates file tailoring process by including a skeleton file
FTOPEN Begins file tailoring process by opening skeleton library
GETMSG Get the message text, help panel and alarm indicator
GRERROR Provides error information from graphic service calls
GRINIT Initialize the ISPF/GDDM interface
GRTERM Terminates the ISPF/GDDM interface
ISPSTART Initialize ISPF, optionally invoking a panel, command or program
LIBDEF Defines application libraries for user dialog
LIST Write data lines to ISPF list data set from dialog
LMACT Activate a LMF-controlled hierarchy from a dialog
LMCLOSE Closes a data set
LMCOMP Compresses a partitioned data set
LMCOPY Copies partitioned data set members or sequential data sets
LMDEACT Deactivate a LMF-controlled hierarchy from a dialog
LMDFREE Frees a data set list ID created by a LMDINIT
LMDINIT Initiates a data set list by generating an ID for a level/volume
LMDLIST Provide a data set list for a LMDINIT data set list ID
LMERASE Erases an ISPF library or MVS data set
LMFREE Frees the data set associated with a given data-id
LMGET Get another record of a data set
LMHIER Hierarchy structure of the library is indicated in a table
LMINIT Initiates library access services for a data-id
LMMADD Adds an ISPF library or partitioned data set member
LMMDEL Deletes an ISPF library or partitioned data set member
LMMDISP Provides member selection list processing actions
LMMFIND Finds an ISPF library or partitioned data set member
LMMLIST Lists members of an ISPF library or partitioned data set
LMMOVE Moves partitioned data set members or sequential data sets
100
Service Description
LMMREN Renames an ISPF library or partitioned data set member
LMMREP Replaces an ISPF library or partitioned data set member
LMMSTATS Statistics for partitioned data set are saved in variables
LMOPEN Opens a data set
LMPRINT Prints to the list data set
LMPROM Promotes a member or seq. data set to a controlled ISPF library
LMPUT Writes a record to a data set
LMQUERY Queries the data set to obtain the requested information
LMRENAME Renames an ISPF library
LMREVIEW Reviews the controls set for a library
LOG Write a record to the log data set
PQUERY Query a panel definition to extract information
QLIBDEF Query LIBDEF definition
REMPOP Removes a previously created pop-up window
SELECT Starts ISPF dialog execution of panels, commands and/or programs
SETMSG Sets a message to be displayed on next panel
TBADD A row is added to a table
TBBOTTOM Moves the current row pointer (CRP) to last row of the table
TBCLOSE Closes a table and optionally saves a copy in a library
TBCREATE Creates a new table and opens it
TBDELETE Deletes a table row
TBDISPL Display all or part of an ISPF table
TBEND Closes a table without saving it
TBERASE Deletes a table from a table library
TBEXIST Determines if a table key value (row) exists
TBGET Obtain a table row
TBMOD Modify existing row or add new row
TBOPEN Open a table residing in a table library
TBPUT Updates a table row
TBQUERY Requests table information
TBSARG Sets the search argument for a following TBSCAN or TBDISPL
TBSAVE Saves an opened table to a library without closing the table
TBSCAN Scans for a table row matching TBSARG set or supplied list
TBSKIP Moves the CRP either direction a specified number of rows
TBSORT Performs a sort of the table
TBSTATS Obtains table statistics
TBTOP Places the CRP ahead of the first row of the table
TBVCLEAR Clears all related table variables to null values
VCOPY Allows a program to copy a variable value
VDEFINE Allows a program to access/define a variable
VDELETE Allows a program to remove variable definition/access from ISPF
VERASE Removes variables from shared and/or profile pool(s)
VGET Obtains a variable value from shared or profile pool
VIEW Allows you to view data as if in EDIT mode
VPUT Updates variable values in shared or profile pool
VREPLACE Allows a program to update variables in the shared/profile pool
VRESET Allows a program to remove all its variable definitions at once
101
The EDIT ISPF/PDF Service
Example
DSNAM = ‘CCI.U.PKXXX.T001.AP.T8150’
"ISPEXEC EDIT DATASET('&DSNAM'),MACRO(CHGMANDZ)"
Here ‘CHGMANDZ’ is the name of ISREDIT MACRO.
102
The DISPLAY ISPF Service
Example
“ISPEXEC DISPLAY PANEL(COMPILE)”
103
The LIBDEF ISPF Service
104
The VGET ISPF Service
105
The VGET ISPF Service
Example#1
106
The VPUT ISPF Service
107
The VPUT ISPF Service
Example
VPUT service is used in the panel proc for copying the values of entered fields to
the shared pool. See the Panels in the Advanced section.
108
The FTOPEN ISPF Service
109
The FTINCL ISPF Service
110
The FTINCL ISPF Service
Example#1
This example show how file tailoring will use the skeleton PHONSKEL from the
file tailoring skeleton library.
Example#2
SKLNAME = 'CMPSUBB'
"ISPEXEC FTOPEN TEMP"
"ISPEXEC FTINCL " SKLNAME
"FTCLOSE"
"VGET (ZTEMPF)"
ADDRESS TSO SUBMIT ‘&ZTEMPF’
Here, the skeleton ‘CMPSUBB’ is used to generate the temporary file tailoring
output .
111
REFERENCES
112