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


ISRCHGS macro

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

The ISRCHGS macro (Figure 1) identifies the lines most recently changed by showing only those lines and excluding all others. When no level is passed, the latest level is assumed. A label range can also be passed to ISRCHGS to limit the search. This macro relies on the modification level maintained by the editor for members with numbers and ISPF statistics.

Operands can also be specified. For example, to show lines with level 8 or greater on a line range:
 Command ===> ISRCHGS 8 .FIRST .LAST
Figure 1. ISRCHGS macro
/*********************************************************************/ 00010003
/*                                                                   */ 00020003
/* 5647-A01 (C) COPYRIGHT IBM CORP 1995, 2003                        */ 00030003
/*                                                                   */ 00040003
/* ISRCHGS - shows the most recent changes to a data set             */ 00050003
/*                                                                   */ 00060003
/*********************************************************************/ 00070003
 ISREDIT MACRO (SEARCH,PARMS)                                           00080003
                                                                        00090003
 ISREDIT (SAVE) = USER_STATE                                            00100003
 ISREDIT (NUMBER, NUMTYPE) = NUMBER                                     00110003
 SET SYSDVAL = &NUMTYPE                                                 00120003
 READDVAL STD COBOL DISPLAY                                             00130003
 ISREDIT (STATS) = STATS                                                00140003
 ISREDIT (LEVEL) = LEVEL                                                00150003
                                                                        00160003
 IF &SEARCH = &STR() | &SUBSTR(1:1,&STR(&SEARCH. )) = &STR(.) THEN DO   00170008
   SET PARMS = &STR(&SEARCH &PARMS)                                     00180003
   SET SEARCH = &LEVEL                                                  00190003
 END                                                                    00200003
                                                                        00210003
 IF &STATS = OFF | &NUMBER = OFF | &STD = NOSTD THEN DO                 00220003
   SET ZEDSMSG = &STR(INVALID DATA)                                     00230003
   SET ZEDLMSG = &STR(BOTH NUMBER AND STATS MODE MUST BE ON)            00240003
   ISPEXEC SETMSG MSG(ISRZ001)                                          00250003
   EXIT CODE(8)                                                         00260003
 END                                                                    00270003
                                                                        00280003
 IF &DATATYPE(&SEARCH) = CHAR THEN DO                                   00290003
   SET ZEDSMSG = &STR(INVALID ARG)                                      00300003
   SET ZEDLMSG = &STR(SEARCH STRING MUST BE FIRST)                      00310003
   ISPEXEC SETMSG MSG(ISRZ001)                                          00320003
   EXIT CODE(8)                                                         00330003
 END                                                                    00340003
                                                                        00350003
 ISREDIT NUMBER = OFF                                                   00360007
 ISREDIT (RECFM) = RECFM                                                00370003
 IF &RECFM = F THEN DO                                                  00380003
   ISREDIT (LRECL) = LRECL                                              00390003
   SET COL1 = &LRECL - 1                                                00400003
   SET COL2 = &LRECL                                                    00410003
 END                                                                    00420003
 ELSE DO                                                                00430003
   SET COL1 = 7                                                         00440003
   SET COL2 = 8                                                         00450003
 END                                                                    00460003
                                                                        00470003
 ISREDIT EXCLUDE ALL                                                    00480003
                                                                        00490003
 DO WHILE &SEARCH <= &LEVEL                                             00500003
   ISREDIT FIND ALL '&SEARCH' &COL1 &COL2 &PARMS                        00510003
   SET SEARCH = &SEARCH + 1                                             00520005
 END                                                                    00530003
                                                                        00530107
 ISREDIT NUMBER = ON                                                    00531007
 ISREDIT USER_STATE = (SAVE)                                            00550003
 EXIT CODE(1)                                                           00560003

This list explains the logical sections of the ISRCHGS macro:

  1. ISRCHGS allows three optional parameters to be passed: a search level and two labels (a label range). If all three are passed, PARMS contains two labels.
    ISREDIT MACRO (SEARCH,PARMS)
  2. The statements shown here save user information, number mode and type, last find string, cursor location, and other profile and status information. Also, stats mode and the current modification level for parameter checking are retrieved, and the three-part number type is divided into three variables.
    ISREDIT (SAVE) = USER_STATE
    ISREDIT (NUMBER, NUMTYPE) = NUMBER
    SET SYSDVAL = &NUMTYPE
    READDVAL STD COBOL DISPLAY
    ISREDIT (STATS) = STATS
    ISREDIT (LEVEL) = LEVEL
  3. ISRCHGS requires that the modification level be entered first if it is specified. This check allows the level to default to the current (highest) modification level. A label range can be specified without a level number; PARMS is reset to capture both labels.
    IF &SEARCH = &STR() | &SUBSTR(1:1,&SEARCH) = &STR(;) THEN -
      DO
        SET PARMS = &STR(&SEARCH &PARMS)
        SET SEARCH = &LEVEL
      END
  4. Check to see if the member modification level is maintained. If not, issue an error message and exit the macro.
    IF &STATS = OFF | &NUMBER = OFF | &STD = NOSTD THEN -
      DO
        SET ZEDSMSG = &STR(INVALID DATA)
        SET ZEDLMSG = &STR(BOTH NUMBER AND STATS MODE MUST BE ON)
        ISPEXEC SETMSG MSG(ISRZ001)
        EXIT CODE(8)
      END
  5. A CLIST DATATYPE function is used to check if the first parameter is valid (a number). If it is not valid, issue an error message and exit from the macro.
    IF &DATATYPE(&SEARCH) = CHAR THEN -
      DO
        SET ZEDSMSG = &STR(INVALID ARG)
        SET ZEDLMSG = &STR(SEARCH STRING MUST BE FIRST)
        ISPEXEC SETMSG MSG(ISRZ001)
        EXIT CODE(8)
      END
  6. Now that validity checks have been passed you can set number mode off. This allows you to treat the number field, which contains the level number, as data.
    ISREDIT NUMBER = OFF
  7. Set &COL1 and &COL2 to the columns containing the level numbers.
    ISREDIT (RECFM) = RECFM
    IF &RECFM = F THEN -
      DO
        ISREDIT (LRECL) = LRECL
        SET COL1 = &LRECL - 1
        SET COL2 = &LRECL
       END
      ELSE DO
        SET COL1 = 7
        SET COL2 = 8
       END
  8. Exclude all lines.
    ISREDIT EXCLUDE ALL
  9. For each level, find all occurrences of the current modification level. If a label range was specified, it is in the PARMS variable. All lines with matching levels are excluded.
    DO WHILE &SEARCH <= &LEVEL
      ISREDIT FIND ALL '&SEARCH' &COL1 &COL2 &PARMS
      SEARCH = &SEARCH + 1
    END
  10. Restore user values, especially number mode.
    ISREDIT USER_STATE = (SAVE)

In the example in Figure 2 the data contains lines that you have changed.

Figure 2. ISRCHGS macro - before running
Screen dump.

When you press Enter, the FINDGHGS macro displays the changed lines and excludes the others, as shown in Figure 3.

Figure 3. ISRCHGS macro - after running
Screen dump.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014