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


Passing parameters, and retrieving and returning information

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

You can also write macros to get information from other users and from the editor, and to display messages to other users. The ISRCOUNT macro, as shown in Figure 1, finds occurrences of the string TEST from the previous example, counts them, and prepares a return message.

Figure 1. ISRCOUNT macro
/*********************************************************************/
/*                                                                   */
/* 5647-A01 (C) COPYRIGHT IBM CORP 1995, 2003                        */
/*                                                                   */
/* ISRCOUNT counts the number of occurrences of a string, and        */
/*          returns a message.                                       */
/*                                                                   */
/*********************************************************************/
ISREDIT MACRO (PARMSTR)
  ISREDIT SEEK ALL &PARMSTR
  IF &LASTCC > 12 THEN DO
    SET &ZEDSMSG = &STR(SEEK ERROR )
    SET &ZEDLMSG = &STR(STRING NOT FOUND )
  END
  ELSE DO
    ISREDIT (COUNT) = SEEK_COUNTS
    SET &COUNT = &COUNT
    SET &ZEDSMSG = &STR("&PARMSTR" FOUND &COUNT TIMES)
    SET &ZEDLMSG = &STR(THE STRING "&PARMSTR " WAS FOUND +
                     &COUNT TIMES.)
  END
  ISPEXEC SETMSG MSG(ISRZ000)
EXIT CODE (0)

To run the ISRCOUNT macro, type isrcount TEST on the command line (Figure 2). The macro does not change the data but displays return messages to show the number of times it found the string. The editor always displays the short message in the upper right corner of the screen. Enter HELP (the default is F1) to produce the long message (Figure 3).

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

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014