EasyManuals Logo

IBM TSO/E REXX User Manual

IBM TSO/E REXX
242 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #100 background imageLoading...
Page #100 background image
function(argument1,argument2,argument3,..........)
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 .......
The names of the arguments on the function call and the ARG instruction do not
have to be the same because information is not passed by argument name but by
position. The first argument sent becomes the first argument received and so forth.
You can also set up a template in the function call, which is then used in the
corresponding ARG instruction. For information about parsing templates, see
Parsing Data on page 87.
The following exec sends information to an internal function that computes the
perimeter of a rectangle. The function returns a value in the variable perim that is
specified after the RETURN instruction. The main exec uses the value in perim to
replace the function call.
Notice the positional relationships between long and length, and wide and width.
Also notice that information is received from variable perim to replace the function
call.
Using the ARG Built-in Function: Another way for a function to receive
arguments is with the ARG built-in function. This built-in function returns the value
of a particular argument specified by a number that represents the argument
position.
For instance, in the previous example, instead of the ARG instruction,
ARG length, width
you can use the ARG function as follows:
length = ARG(1) /* puts the first argument into length */
width = ARG(2) /* puts the second argument into width */
More information about the ARG function appears in z/OS TSO/E REXX Reference.
Example of an Internal Function
/* This exec receives as arguments the length and width of a */
/******************************** REXX *********************************** /
/* rectangle and passes that information to an internal function */
/* named perimeter. The function then calculates the perimeter of */
/*************************************************************************** /
/* the rectangle. */
PARSE ARG long wide
SAY 'The perimeter is' perimeter(long,wide) 'inches.'
EXIT
perimeter:
ARG length, width
perim = 2 * length + 2 * width
RETURN perim
Writing a Function
82
z/OS V1R1.0 TSO/E REXX Users Guide

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM TSO/E REXX and is the answer not in the manual?

IBM TSO/E REXX Specifications

General IconGeneral
BrandIBM
ModelTSO/E REXX
CategoryComputer Hardware
LanguageEnglish

Related product manuals