z/OS ISPF Edit and Edit Macros
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Passing parameters to a macro

z/OS ISPF Edit and Edit Macros
SC19-3621-00

A parameter can be either a simple string or a quoted string. It can be passed by using the standard method of putting variables into shared and profile pools (use VPUT in dialogs and VGET in initial macros). This method is best suited to parameters passed from one dialog to another, as in an edit macro.

You can enter parameters along with an edit macro name as a primary command by using the MACRO command. This command allows you to identify the names of one or more variables to contain any passed parameters.

Note: For edit line macros, only one parameter is passed to the macro. This parameter is the line command, including any repetition, as it was entered on the line.

For more information, see Working with an edit line command table.

It is an error to enter parameter values for a macro without parameter variables. If you make this mistake, the editor displays a message. It is not an error if you supply more or fewer parameters than the number of variables that are included on the MACRO command. When you are writing a macro, check for omissions and the order of parameters.

Multiple parameters are placed into one or more variables based on the number of variables specified in the MACRO command. If you include more than one variable name, the editor stores the parameters in order (the first parameter in the first variable, the second in the second, and so on). Note that assignment to variables is by position only.

If there are more parameters entered than there are variables available, the editor stores the remaining parameters as 1 character string in the last variable. If you include only one variable name on the MACRO command, that variable contains all the parameters entered with the macro name. If there are more variable names than parameters, the unused variables are set to nulls.

Multiple parameters are separated by a blank or comma, or a quoted string that is separated by a blank or comma. Quotes can be single (') or double ("). If you want your FIXIT macro to accept two parameters, for example, you can include this command:
CLIST Statement REXX Statements
 
ISREDIT MACRO (PARM1,PARM2,REST)
ADDRESS ISPEXEC
'ISREDIT MACRO (PARM1,PARM2,REST)'
This means that if you enter:
FIXIT GOOD BAD AND UGLY
variable PARM1 is assigned the value "GOOD", PARM2 is assigned the value "BAD", and REST is assigned the value "AND UGLY".
If the parameters passed were GOOD BAD, variable REST would be null. Also, if the parameters are enclosed in quotation marks, such as:
FIXIT 'GOOD BAD' 'AND UGLY'
PARM1 would be set to "GOOD BAD", PARM2 would be set to "AND UGLY", and REST would be null.
For another example, see the ISRTRYIT macro (Figure 1). If the MACRO statement contains two variables (ISREDIT MACRO (command,parm)), entering:
ISRTRYIT RESET
sets the variables command to "RESET" and parm to null. Conversely, this command:
ISRTRYIT FIND A
sets command to "FIND" and parm to "A". To find out what was actually typed on the command line, a macro may examine the variable ZEDITCMD, which is in the shared variable pool. ZEDITCMD is a character variable, the length if which depends on the length of the command entered. Therefore, you should either VDEFINE ZEDITCMD to be sufficiently large to hold the expected command, or use the VCOPY service to get the length.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014