Mainframe Utility: INFRONT

Return to Mainframe Utilities Page

Module


/**********************************************************************
/* EDIT MACRO : INFRONT                                               *
/* AUTHOR     : DAVID LEIGH                                           *
/* FUNCTION   : PLACE A STRING IN COLUMN 1 OF EVERY IDENTIFIED LINE   *
/*              TO BE PROCESSED.  DATA IS SHIFTED RIGHT (CREATING     *
/*              TRUNCATION IF NECESSARY) BY THE NUMBER OF BYTES IN    *
/*              THE INPUT STRING.                                     *
/**********************************************************************
ISREDIT MACRO (STRING,VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8,VAR9)
ISPEXEC CONTROL ERRORS RETURN
ISPEXEC VGET (DBGSWTCH) PROFILE
IF &DBGSWTCH = &STR(ON) THEN +
     CONTROL MSG LIST CONLIST SYMLIST NOFLUSH ASIS
ELSE  CONTROL NOMSG NOLIST NOFLUSH NOPROMPT ASIS

ISREDIT (SLN,SCL) = CURSOR

IF &STR(&SYSNSUB(1,&STRING)) = HELP THEN GOTO HELPSEC
DO &X = 1 TO 9
    SET VARIABLES = &SYSCAPS(&STR(&VARIABLES &&VAR&X))
END

IF &STR(&VARIABLES) =    THEN +
    DO
        %YOUSURE COLUMN(10) ROW(5) ZWINTTL('PROCESS ALL LINES?!')
        IF &LASTCC > 0 THEN +
            DO
                SET ZEDLMSG = &STR(*** NO "INFRONT" PROCESSING +
                                   PERFORMED ***)
                ISPEXEC SETMSG MSG(UTLZ001)
                EXIT
            END
    END

IF (&SUBSTR(1:1,&STR(&SYSNSUB(1,&STRING))) = &STR(') AND +
    &SUBSTR(&LENGTH(&STR(&SYSNSUB(1,&STRING))):+
            &LENGTH(&STR(&SYSNSUB(1,&STRING))),+
    &STR(&SYSNSUB(1,&STRING))) = &STR(')) OR +
   (&SUBSTR(1:1,&STR(&SYSNSUB(1,&STRING))) = &STR(") AND +
    &SUBSTR(&LENGTH(&STR(&SYSNSUB(1,&STRING))):+
            &LENGTH(&STR(&SYSNSUB(1,&STRING))),+
    &STR(&SYSNSUB(1,&STRING))) = &STR(")) THEN +
    SET STRING = +
        &SUBSTR(2:&EVAL(&LENGTH(&STR(&SYSNSUB(1,&STRING))) - 1),+
        &STR(&SYSNSUB(1,&STRING)))

IF &SYSINDEX(&STR('),&STR(&SYSNSUB(1,&STRING))) > 0 AND +
   &SYSINDEX(&STR("),&STR(&SYSNSUB(1,&STRING))) > 0 THEN +
    DO
        SET ZEDLMSG = &STR(*** "INFRONT" CANNOT PROCESS +
                           STRINGS WITH BOTH SINGLE AND +
                           DOUBLE QOUTES ***)
        ISPEXEC SETMSG MSG(UTLZ001)
        EXIT CODE(8)
    END

SET ZEDLMSG = &STR(PLACING "&STRING" IN FRONT OF LINES W/CRITERIA +
                   "&VARIABLES")
ISPEXEC CONTROL DISPLAY LOCK
ISPEXEC DISPLAY MSG(UTLZ000W)

SET QT = &STR(')

IF &SYSINDEX(&STR('),&STR(&SYSNSUB(1,&STRING))) > 0 THEN +
    SET QT = &STR(")

SET SLEN = &LENGTH(&STR(&SYSNSUB(1,&STRING)))
DO &I = 1 TO &SLEN
    SET EQUALS = &STR(&EQUALS=)
END

ISREDIT (SLN,SCL) = CURSOR

ISREDIT FIND FIRST P'=' 1 &VARIABLES
DO WHILE &LASTCC = 0
    ISREDIT SHIFT ) .ZCSR &SLEN
    ISREDIT CHANGE FIRST P'&STR(&EQUALS)' +
            '&STR(&SYSNSUB(1,&STRING))' 1 .ZCSR .ZCSR
    SET GOOD = &GOOD + 1
    ISREDIT FIND LAST P'=' .ZCSR .ZCSR
    ISREDIT FIND NEXT P'=' 1 &VARIABLES
END

SET ZEDLMSG = &STR(*** PROCESSED &GOOD LINES ***)
ISPEXEC SETMSG MSG(UTLZ000)

ISREDIT CURSOR = &SLN &SCL

EXIT

HELPSEC: +                                                              02480000
ISPEXEC SELECT PGM(ISPTUTOR) PARM(HELPSHEL)                             02490000
SET ZEDLMSG = &STR(*** HELP DISPLAYED FOR INFRONT UTILITY +             02490000
                   *** NO PROCESSING PERFORMED ***)                     02490000
ISPEXEC SETMSG MSG(UTLZ000)                                             02490000
EXIT
            


Documentation


 INFRONT is an edit macro which places a string in column 1 of every selected
 line and shifts the data (allowing truncation on the right if necessary) to the
 right by the amount of the length of the specified string.

 Lines are selected for processing by specifying such things as "X" or "NX" to
 indicate an excluded status of lines and/or edit labels to indicate a range of
 lines.  Specifying nothing will cause ALL lines in the file to be processed.
 If no parameter is specified, you will be prompted to make sure you really want
 to process all lines in the file.

 EXAMPLES:

 Place string "abc" in front of all excluded lines.

 "before" processing:

 x00017 11111111
 000018 22222222
 0x0019 33333333
 000020 44444444
 00x021 55555555

 COMMAND ===> infront 'abc' x

 "after" processing:

 000017 abc11111111
 000018 22222222
 000019 abc33333333
 000020 44444444
 000021 abc55555555

 Place string "abc" in front of all excluded lines in label range .a .b

 "before" processing:

 x00017 11111111
 .a0018 22222222
 0x0019 33333333
 .b0020 44444444
 00x021 55555555

 COMMAND ===> infront 'abc' x

 "after" processing:

 000017 11111111
 .A     22222222
 000019 abc33333333
 .B     44444444
 000021 55555555
            


Leave a Reply

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