The sample macro shown below contains a variety of REXX commands and Editor commands and parameters commonly found in user-defined macros. Editor commands, parameters, and their options are enclosed in quote marks.
Select any highlighted element to get more information on that element. This section provides only a minimal guide to macro programming for the Editor. Refer to a REXX language and programming reference for more information on REXX programming, and the Editor Reference for information about the complete set of Editorcommands and parameters.
/* This macro repeats a command a given number of times */
/* Two dialogs are issued - the first collects the number */
/* the second the command to repeat */
/* Note: if a number is not entered the macro ends and a message is issued */
/* Note: only valid editor commands are accepted on the second dialog */
'set lineread.title Repeat a Command'
'set lineread.prompt Enter the number of times to repeat:'
'lineread 255'
'extract lastkey'
if lastkey = 'ENTER' then do
'extract lastline'
end
if datatype(lastline) = NUM /* check that a number was entered */
then do
numrep = lastline
end
else do
'msg You must enter a valid number'
return
end
/* get the second piece of information */
'set lineread.title Repeat a Command'
'set lineread.prompt Enter the command to repeat:'
'lineread 255'
'extract lastkey'
if lastkey = 'ENTER' then do
'extract lastline'
end
cmd_rep = lastline
/* substitute the values entered and run repeat command */
'repeat' numrep cmd_rep
![]()
Specify Conditions in Editor Macros
Perform Arithmetic Expressions in Editor
Macros
Perform Constants and Variables in Editor
Macros
Perform the IF Statement in Editor Macros
Perform Loops in Editor Macros
Perform REXX Functions in Editor Macros
