|
|||||||||||
|
Chicago-Soft
|
ISPF Edit Macro for Matching Skeleton SEL/ENDSEL Statements Figure 1: Macro SourceDownload this macro in text format (SEL-F1.TXT)
/*************************************/
/*EDIT MACRO TO IDENTIFY ISPF SKELETON )SEL AND ) ENDSEL */
/* MISMATCHES. IF NO MISMATCHES EXIST ALL )SEL-)ENDSEL PAIRS WILL BE MATCHED AND
IDENTIFIED WITH A COMMENT IN COLUMNS 55 - 71 */
/*************************************************/
ISREDIT MACRO
ISPEXEC CONTROL ERRORS RETURN
COUNTSEL: +
ISREDIT SEEK ')SEL' NX ALL 1 4 /* Find all )SEL */
ISREDIT(SELCNT) = SEEK_COUNTS /* Save count for )SEL */
COUNTEND: +
ISREDIT SEEK ')ENDSEL' NX ALL 1 7 /* Find all )ENDSEL */
ISREDIT(ENDCNT) = SEEK_COUNTS /* Save cnt for )ENDSEL */
IF &SELCNT = &ENDCNT THEN GOTO MATCH /* )SEL cnt = )END cnt */
IF &SELCNT ^= &ENDCNT THEN GOTO NOMATCH /* )SEL cnt ^= )END cnt */
NOMATCH: +
ISREDIT EXCLUDE ALL /*Exclude all lines in mem */
ISREDIT CURSOR = 1 1 /* Position cursor at line 1 */
ISREDIT FIND ')SEL' ALL 1 4 /* Display all )SEL lines */
ISREDIT CURSOR = 1 1 /* Position cursor at line 1 */
ISREDIT FIND ')ENDSEL' ALL 1 7 /* Display all )ENDSEL ln */
ISREDIT CURSOR = 1 1 /* Position cursor at line 1 */
NOMLOOP: +
ISREDIT FIND ')ENDSEL' NX NEXT 1 7 /* Find next non-excld )END */
SET FINDCC = &LASTCC /* Save return code */
IF &FINDCC > 0 THEN GOTO NMTCHEND /* If rc > 0 go to end sect. */
ISREDIT EXCLUDE )SEL PREV /* Else excld matching )SEL */
SET ELCLCC = &LASTCC /* Save return code */
IF &EXCLCC > 0 THEN GOTO NOMLOOP /* If rc > 0 goto loop begin */
ISREDIT EXCLUDE )ENDSEL NEXT /* Else excld )ENDSEL */
GOTO NOMLOOP /* GOTO beginning of loop */
MATCH: +
ISREDIT (ROW,COL) = CURSOR /* Set &row &col to cursor pos */
ISREDIT EXCLUDE ALL /* Exclude all lines in mem */
ISREDIT CURSOR = 1 1 /* Positon cursor to line 1 */
ISREDIT FIND ')SEL' ALL 1 4 /* Display all )SEL lines */
ISREDIT CURSOR = 1 1 /* Position cursor to line 1 */
ISREDIT FIND ')ENDSEL' ALL 1 7 /* Display all )ENDSEL lines */
SET CTR = 0 /* Init incremental counter */
MLOOP: +
ISREDIT CURSOR = 1 1 /* Position cursor to line 1 */
SET CTR = &CTR + 1 /* Increment counter */
ISREDIT FIND ')ENDSEL' NX NEXT 1 7 /* Find next non-excld )END */
SET FINDCC = &LASTCC /* Save return code */
IF &FINDCC > 0 THEN GOTO MTCHEND /* If rc > 0 goto end sect. */
ISREDIT (ROW,COL) = CURSOR /* Set values for &row, &col */
/* Modify )END to add ctr */
ISREDIT LINE &ROW = < 1 ')ENDSEL' 55 ' /*' 59 'ENDSEL-&CTR' 70 '*/'
ISREDIT EXCLUDE )SEL PREV /* Exclude prev )SEL stmt */
ISREDIT (ROW,COL) = CURSOR /* Set values for &row, &col */
/* Insert ctr comment B4 )SEL */
ISREDIT LINE_BEFORE &ROW = < 1 ')CM' 55 ' /*' 59 'SEL-&CTR' 70 '*/'>
ISREDIT (ROW,COL) = CURSOR /* Set values for &row, &col */
SET ROW = &ROW - 2 /* Subtract 2 from &row val */
ISREDIT CURSOR = &ROW &COL /* Reposition cursor */
ISREDIT (HOLDLN) = LINE &ROW /* HOLDLN = cur line content */
SET HOLDLN1 = &SUBSTR(2:4,&HOLDLN) /* Parse holdln into holdln1 */
IF &STR(&HOLDLN1) = &STR(CM ) THEN DO /* If )CM already exists */
SET HOLDLN2 = &SUBSTR(59:62,&HOLDLN) /* Parse holdln into holdln2 */
IF &STR(&HOLDLN2) = &STR(SEL-) THEN DO /* If )CM is a sel type */
ISREDIT DELETE &ROW /* Delete old )SEL comment */
END /* End of DO loop */
END /* End of DO loop */
ISREDIT EXCLUDE )ENDSEL NEXT /* Exclude next )ENDSEL */
GOTO MLOOP /* GOTO beginning of loop */
NMTCHEND: +
IF &MAXCC > 0 THEN /* If max return code > 0 */
DO /* THEN */
SET SELTOT = &SELCNT /* Set )SEL count to print */
SET ENDTOT = &ENDCNT /* Set )ENDSEL count to prt */
SET ZEDSMSG = &STR(&SELTOT SEL, &ENDTOT ENDSEL) /* Set short msg */
SET ZEDLMSG = &STR(LONG MESSAGE NOT USED) /* Set long msg */
ISPEXEC SETMSG MSG(ISRZ001) /* Set msg to display on exit */
END /* End of DO loop */
GOTO EXITALL /* Exit macro */
MTCHEND: +
IF &MAXCC > 0 THEN /* If max rc > 0 */
DO /* THEN */
SET SELTOT = &STLCNT /* Set )SEL count to print */
SET ZEDSMSG = &STR(&SELTOT SEL/ENDSEL MATCHED) /* Set short msg */
SET ZEDLMSG = &STR(LONG MESSAGE NOT USED) /* Set long msg */
ISPEXEC SETMSG MSG(ISRZ001) /* Set msg to display on exit */
END /* End of DO loop */
ISREDIT RESET /* Reset edit display */
GOTO EXITALL /* GOTO exit */
EXITALL: +
ISREDIT CURSOR = .ZFIRST 0 /* Reposition cursor */
EXIT CODE(0) /* Exit macro */
|
|
||||||||
home · current
articles
· archives · forums · |