MainframeSupports
tip week 46/2004:

It is now time for a tip about EDIT macros. In this week I will tell you about how to process line commands in your personal EDIT macro. As usual I will start with an example that show you all the nice details:

/* REXX */
ADDRESS ISREDIT
"MACRO NOPROCESS"
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
"PROCESS RANGE S"
IF RC = 0
THEN DO
  "(FRSTLINE) = LINENUM .ZFRANGE"
  "(LASTLINE) = LINENUM .ZLRANGE"
  IF FRSTLINE = LASTLINE
  THEN
    CALL ISPF_MESSAGE 'One line selected', 'Line 'FRSTLINE' selected'
  ELSE
    CALL ISPF_MESSAGE 'More lines selected',,
                      'Lines 'FRSTLINE'-'LASTLINE' selected'
END
ELSE IF RC = 4 OR RC = 20
THEN
  CALL ISPF_MESSAGE 'Line command missing', 'Use S as line command'
ELSE IF RC = 16
THEN DO
  "(CMDUSED) = RANGE_CMD"
  IF CMDUSED = 'S'
  THEN
    CALL ISPF_MESSAGE 'Line command incomplete', 'SS command missing'
  ELSE
    CALL ISPF_MESSAGE 'Wrong line command',,
                      'Line command 'CMDUSED' invalid'
END
EXIT

There may be spelling errors because the EDIT macro is a rewrite of a lot more complicated version. This EDIT macro is also missing the procedure ISPF_MESSAGE.

Option NOPROCESS is mandatory on the MACRO command in order to make your EDIT macro understand and accept line commands. Next you have to include command PROCESS to indicate which line commands you want to accept and how. I have chosen a block command (RANGE) called S. You can use existing line command and you can have more of them separated by blanks.

The return code from the PROCESS command determines what to do next. Return code 0 is OK and now you have access to the two system defined labels .ZFRANGE and .ZLRANGE when you use option RANGE on the PROCESS command. .ZFRANGE indicates the first line in the block and .ZLRANGE the last line. The meaning of the other return codes are indicated in the example. The EDIT macro function RANGE_CMD returns the line command in use. You have to use it with return code 0 from the PROCESS command if you have chosen to use more than one line command.

Previous tip in english        Sidste danske tip        Tip list