Mainframe Utility: MARK

Return to Mainframe Utilities Page

Module


ISREDIT MACRO (STRING1,BOOLEAN,STRING2,OPTION)
ISPEXEC CONTROL ERRORS RETURN
/**** SET MESSAGE DISPLAY ON/OFF BASED ON THE DEBUG SWITCH ***/
ISPEXEC VGET (DBGSWTCH) PROFILE
IF &DBGSWTCH = &STR(ON) THEN CONTROL MSG LIST CONLIST SYMLIST NOFLUSH
ELSE CONTROL NOMSG NOLIST NOFLUSH NOPROMPT
/******************************************************************/
/* 'MARK' EDIT MACRO. MARK A LINE WHICH MEETS THE INPUT CRITERIA. */
/* AUTHOR : DAVID LEIGH    DATE : 1-10-89                         */
/******************************************************************/

SET MARK = &STR($MARK$)
IF &LENGTH(&STR(&BOOLEAN)) = 0 THEN +
    IF &STR(&STRING1) = &STR(HELP) THEN GOTO HELPSEC
    ELSE +
        DO
            SET ZEDSMSG = &STR(BOOLEAN MISSING)
            SET ZEDLMSG = &STR(SPECIFY 1 OR 2 STRINGS WITH A BOOLEAN) +
                          &STR(OPERATOR - INVOKE W/'HELP' FOR HELP)
            ISPEXEC SETMSG MSG(UTLZ001)
            EXIT CODE(4)
        END
ELSE +
    IF &STR(&BOOLEAN) ¬= &STR(AND) AND +
       &STR(&BOOLEAN) ¬= &STR(OR) AND +
       &STR(&BOOLEAN) ¬= &STR(NOR) AND +
       &STR(&BOOLEAN) ¬= &STR(NOT) THEN +
        DO
            SET ZEDSMSG = &STR(BOOLEAN INVALID)
            SET ZEDLMSG = &STR(VALID BOOLEANS ARE : 'AND' 'OR' 'NOR') +
                          &STR('NOT' - INVOKE WITH 'HELP' FOR MORE HELP)
            ISPEXEC SETMSG MSG(UTLZ001)
            EXIT CODE(4)
        END

SET SLEN1 = &LENGTH(&STR(&STRING1))
SET SLEN2 = &LENGTH(&STR(&STRING2))

IF &SUBSTR(1:1,&STR(&STRING1)) = &STR(') AND +
   &SUBSTR(&SLEN1:&SLEN1,&STR(&STRING1)) = &STR(') THEN +
    DO
        SET SLEN1 = &SLEN1 - 1
        IF &SLEN1 > 1 THEN SET STRING1 = &SUBSTR(2:&SLEN1,&STR(&STRING1)
    END

IF &SUBSTR(1:1,&STR(&STRING2)) = &STR(') AND +
   &SUBSTR(&SLEN2:&SLEN2,&STR(&STRING2)) = &STR(') THEN +
    DO
        SET SLEN2 = &SLEN2 - 1
        IF &SLEN2 > 1 THEN SET STRING2 = &SUBSTR(2:&SLEN2,&STR(&STRING2)
    END

ISREDIT (SLINE,SCOL) = CURSOR
SET COUNT = 0
ISREDIT CURSOR = 1 0
ISREDIT (TLINE) = LINE .ZCSR
SET MAXCC = 0
IF &OPTION = &STR(END) THEN +
    DO
        ISREDIT (RECLEN) = LRECL
        SET MRKPOS = &RECLEN - 5
        SET LINLEN = &MRKPOS - 1
    END

DO WHILE &MAXCC = 0

    IF &BOOLEAN = &STR(AND) THEN +
        DO
            IF &SYSINDEX(&STR(&STRING1),&NRSTR(&TLINE)) > 0 AND +
               &SYSINDEX(&STR(&STRING2),&NRSTR(&TLINE)) > 0 THEN +
                DO
                    IF &OPTION = &STR(OVERLAY) THEN +
                        DO
                            SET A = &LENGTH(&STR(&MARK))
                            SET B = &A + 1
                            SET C = &LENGTH(&NRSTR(&TLINE))
                            SET TLINE = &STR(&MARK)+
                                        &SUBSTR(&B:&C,&NRSTR(&TLINE))
                        END
                    ELSE +
                        IF &OPTION = &STR(END) THEN SET TLINE = +
                           &SUBSTR(1:&LINLEN,&NRSTR(&TLINE))&STR(&MARK)
                        ELSE +
                            SET TLINE = &NRSTR(&MARK&TLINE)
                    ISREDIT LINE .ZCSR = '&TLINE'
                    SET COUNT = &COUNT + 1
                END
        END
    IF &BOOLEAN = &STR(OR) THEN +
        DO
            IF &SYSINDEX(&STR(&STRING1),&NRSTR(&TLINE)) > 0 OR +
               &SYSINDEX(&STR(&STRING2),&NRSTR(&TLINE)) > 0 THEN +
                DO
                    IF &OPTION = &STR(OVERLAY) THEN +
                        DO
                            SET A = &LENGTH(&STR(&MARK))
                            SET B = &A + 1
                            SET C = &LENGTH(&NRSTR(&TLINE))
                            SET TLINE = &STR(&MARK)+
                                        &SUBSTR(&B:&C,&NRSTR(&TLINE))
                        END
                    ELSE +
                        IF &OPTION = &STR(END) THEN SET TLINE = +
                           &SUBSTR(1:&LINLEN,&NRSTR(&TLINE))&STR(&MARK)
                        ELSE +
                            SET TLINE = &NRSTR(&MARK&TLINE)
                    ISREDIT LINE .ZCSR = '&TLINE'
                    SET COUNT = &COUNT + 1
                END
        END
    IF &BOOLEAN = &STR(NOR) THEN +
        DO
            IF &SYSINDEX(&STR(&STRING1),&NRSTR(&TLINE)) = 0 AND +
               &SYSINDEX(&STR(&STRING2),&NRSTR(&TLINE)) = 0 THEN +
                DO
                    IF &OPTION = &STR(OVERLAY) THEN +
                        DO
                            SET A = &LENGTH(&STR(&MARK))
                            SET B = &A + 1
                            SET C = &LENGTH(&NRSTR(&TLINE))
                            SET TLINE = &STR(&MARK)+
                                        &SUBSTR(&B:&C,&NRSTR(&TLINE))
                        END
                    ELSE +
                        IF &OPTION = &STR(END) THEN SET TLINE = +
                           &SUBSTR(1:&LINLEN,&NRSTR(&TLINE))&STR(&MARK)
                        ELSE +
                            SET TLINE = &NRSTR(&MARK&TLINE)
                    ISREDIT LINE .ZCSR = '&TLINE'
                    SET COUNT = &COUNT + 1
                END
        END
    IF &BOOLEAN = &STR(NOT) THEN +
        DO
            IF &SYSINDEX(&STR(&STRING1),&NRSTR(&TLINE)) > 0 AND +
               &SYSINDEX(&STR(&STRING2),&NRSTR(&TLINE)) = 0 THEN +
                DO
                    IF &OPTION = &STR(OVERLAY) THEN +
                        DO
                            SET A = &LENGTH(&STR(&MARK))
                            SET B = &A + 1
                            SET C = &LENGTH(&NRSTR(&TLINE))
                            SET TLINE = &STR(&MARK)+
                                        &SUBSTR(&B:&C,&NRSTR(&TLINE))
                        END
                    ELSE +
                        IF &OPTION = &STR(END) THEN SET TLINE = +
                           &SUBSTR(1:&LINLEN,&NRSTR(&TLINE))&STR(&MARK)
                        ELSE +
                            SET TLINE = &NRSTR(&MARK&TLINE)
                    ISREDIT LINE .ZCSR = '&TLINE'
                    SET COUNT = &COUNT + 1
                END
        END
    ISREDIT (LN,CL) = CURSOR
    SET LN = &LN + 1
    SET MAXCC = 0
    ISREDIT CURSOR = &LN 0
    ISREDIT (TLINE) = LINE .ZCSR
END

ISREDIT CURSOR = &SLINE &SCOL
SET ZEDSMSG = &STR(&COUNT LINES MARKED)
IF &OPTION = &STR(END) THEN +
    SET ZEDLMSG = &STR(THE MARKED LINES ARE SUFFIXED WITH '&MARK')
ELSE +
    SET ZEDLMSG = &STR(THE MARKED LINES ARE PREFIXED WITH '&MARK')
ISPEXEC SETMSG MSG(UTLZ000)

EXIT

HELPSEC: +
CLEAR
WRITE *** HELP FOR EDIT MACRO 'MARK' ***
WRITE
WRITE THE 'MARK' EDIT MACRO PREFIXES DATALINES IN A FILE WITH THE
WRITE STRING '&MARK' IF THE DATALINE MEETS THE CRITERIA PASSED BY THE
WRITE USER.  THE CRITERIA CONSISTS OF TWO STRINGS AND A BOOLEAN OPERATOR
WRITE TO TELL THE MACRO WHAT TYPE OF STRING SEARCHES TO MAKE.
WRITE
WRITE BASIC SYNTAX :
WRITE
WRITE COMMAND ===> MARK STRING1 ___ STRING2
WRITE
WRITE WHERE '___' IS ONE OF THE FOLLOWING BOOLEAN SUBSET :
WRITE
WRITE                             'AND' 'OR' 'NOR' 'NOT'
WRITE
WRITE 'AND' SAYS 'MARK THE LINES WHERE BOTH STRING1 AND STRING2 EXIST'.
WRITE
WRITE 'OR' SAYS 'MARK THE LINES WHERE EITHER STRING1 OR STRING2 EXIST'.


WRITE
WRITE 'NOR' SAYS 'MARK THE LINES WHERE NEITHER STRING1 NOR STRING2 EXIST'.
WRITE
WRITE 'NOT' SAYS 'MARK THE LINES WHERE STRING1 EXISTS AND STRING2 DOES NOT'.
WRITE
WRITE
WRITE SPECIAL NOTES : 'MARK' DOES NOT TAKE INTO ACCOUNT THE 'EXCLUDED'
WRITE                 STATUS OF A GIVEN LINE, AND DOES NOT AFFECT THE
WRITE                 EXCLUDED STATUS OF A GIVEN LINE.
WRITE
WRITE                 IF 'END' IS SPECIFIED AS A 4TH PARAMETER, THEN
WRITE                 THE MARK STRING (&MARK) WILL OVERLAY THE RIGHT
WRITE                 MOST CHARACTERS OF THE LINE. (LINE IS "SUFFIXED")
WRITE
WRITE                 IF 'OVERLAY' IS SPECIFIED AS A 4TH PARAMETER, THEN
WRITE                 THE MARK STRING (&MARK) WILL OVERLAY THE LEFT MOST
WRITE                 CHARACTERS OF THE LINE.  IF IT IS NOT SPECIFIED
WRITE                 THEN THE TEXT WILL BE RIGHT SHIFTED BY THE NUMBER
WRITE                 OF CHARACTERS IN THE MARK STRING.  THIS MEANS THAT
WRITE                 THE RIGHT MOST CHARACTERS ON THE LINE WILL BE LOST
WRITE                 IN THE SHIFT.
WRITE
WRITE SYNTAX WOULD BE :
WRITE
WRITE COMMAND ===> MARK STRING1 ___ STRING2 OVERLAY
WRITE
WRITE *** END OF HELP *** NO PROCESSING PERFORMED ***
EXIT
            


Documentation


 This utility will mark lines in a file with the string "$MARK$" in columns 1-6
 if the lines contain any of the following :
                                             string1     AND     string2
                                             string1     OR      string2
                                     neither string1     NOR     string2
                                             string1 and NOT     string2
 The default is for the line to be right shifted 6 positions (truncating any
 data in the right 6 columns, but you can specify OVERLAY when invoking and then
 the data in columns 1-6 will be overlayed with "$MARK$".  Syntax is as follows:

 Command ===> mark abcdef xxx ghijk {overlay}
                   where 'xxx' is AND, OR, NOR or NOT
            


Leave a Reply

Your email address will not be published. Required fields are marked *