The key word in the title is easily. If you search for “Working with an edit line command table”, the documentation gives you instructions on how to create a table, then add your definition, create your macro, and then use it. When you were expecting to do this invisibly for the end user, it is a lot of work.
A command line rexx program can process line commands. I created a command line program so when I use it, and use S or SS..SS line commands, the macro can extract the tagged lines, and so do things with the tagged data.
The command line Rexx
/* REXX */
address isredit
'MACRO (a) NOPROCESS '
'process range S '
IF RC = 0
THEN DO
"(first) = LINENUM .ZFRANGE"
"(last) = LINENUM .ZLRANGE"
data = ""
/* build up a long string from the tagged lines */
do i = first to last
"(l) = LINE (i)"
data = data || strip(l) || " "
end
l = data
address ispexec "edit dataset('COLIN.$$TEMP$$') macro(l2) parm(l)"
END
Where the lines of interest are
- ‘MACRO (a) NOPROCESS ‘
- Usually when a command line macro is processed, ISPF processes any outstanding line commands (such as D) before processing any commands in the rexx exec. The NOPROCESS says – hold off doing this until instructed.
- a is the data passed in
- ‘process range S ‘
- This locates any line commands beginning with S, for a single line, or SS…SS for multiple lins.
- if rc = 0 then do
- “(first) = LINENUM .ZFRANGE”
- get the line number of the First in the RANGE
- “(last) = LINENUM .ZLRANGE”
- get the line number of the Last in the Range.
- data = “”
- do i = first to last /* process the data build up the string */
- “(l) = LINE (i)”
- data = data || strip(l) || ” “
- end
- ldata = data
- address ispexec “edit dataset(‘COLIN.$$TEMP$$’) macro(l2) parm(ldata)”
- Invoke edit on a file – invoke macro l2, and pass the data in the rexx variable ldata
- END
If the “process range” gives a non zero return code, set an error message
else do
zedsmsg = 'You need to specify line prefix s|ss ss'
zedlmsg = 'You need to specify line prefix s|ss ss long message'
address ispexec 'SETMSG MSG(ISRZ001)'
end
This sets a Short message (zedSmsg) which is display at the top right of the display, and a long message (zedLmsg) if the user presses PF1 on the short message.
Macro L2
This macro is processed when the edit dataset(..) macro(l2) command is issued
/* REXX */
address isredit
'MACRO (a) '
say "Passed data" a
...