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


Simplifying complex tasks

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

If you need to perform an involved task, you can include logic in your edit macro. For instance, the ISRTDATA macro shown in Figure 1 creates variations of the same line by first finding the succeeding test string number, and then changing each occurrence, using ascending numbers one through nine.

Figure 1. ISRTDATA macro
/*********************************************************************/
/*                                                                   */
/* 5647-A01 (C) COPYRIGHT IBM CORP 1995, 2003                        */
/*                                                                   */
/* ISRTDATA generates test data                                      */
/*                                                                   */
/*********************************************************************/
ISREDIT MACRO
  SET &COUNT = 1                      /* Start loop counter         */
  DO WHILE &COUNT <= 9                /* Loop up to 9 times         */
    ISREDIT FIND 'TEST - # '          /* Search for 'TEST-#'        */
    SET &RETCODE = &LASTCC            /* Save the FIND return code  */
    IF &RETCODE = 0 THEN              /*                            */ -
      DO                              /* If the string is found,    */
        ISREDIT CHANGE '#' '&COUNT'   /* change '#' to the value    */
        SET &COUNT = &COUNT + 1       /* of '&COUNT', increment     */
      END                             /* the counter by one, and    */
    ELSE                              /* continue the loop.         */ -
      SET &COUNT = 10                 /* If the string is not       */
  END                                 /* found, set the counter to  */
EXIT CODE (0)                         /* exit the loop.             */

To run the test macro, type isrtdata on the command line (Figure 2). The macro numbers the first nine lines of data (Figure 3).

Figure 2. ISRTDATA macro - before running
Screen dump.
Figure 3. ISRTDATA macro - after running
Screen dump.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014