Mainframe Utility: ATEND

Return to Mainframe Utilities Page

Module


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
IF &STR(&STRING) = HELP THEN GOTO HELPSEC
/**********************************************************************
/* EDIT MACRO : ATEND                                                 *
/* AUTHOR     : DAVID LEIGH                                           *
/* FUNCTION   : PLACE A STRING IN THE FIRST BLANK POSITION AFTER THE  *
/*              LAST NON-BLANK POSITION ON EACH LINE MEETING THE      *
/*              PASSED EDIT CRITERIA.                                 *
/**********************************************************************
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 "ATEND" PROCESSING +
                                   PERFORMED ***)
                ISPEXEC SETMSG MSG(UTLZ001)
                EXIT
            END
    END

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

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

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

SET QT = &STR(')

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

ISREDIT (SLN,SCL) = CURSOR

SET BAD = 0
SET GOOD = 0

ISREDIT (LBOUND,RBOUND) = BOUNDS

ISREDIT FIND FIRST P'=' &VARIABLES

DO WHILE &LASTCC = 0
    ISREDIT FIND LAST P'¬' .ZCSR .ZCSR
    IF &LASTCC = 0 THEN SET X = 1
    ELSE SET X = 0
    ISREDIT (LN,CL) = CURSOR
    SET CL = &CL + &X
    IF &CL > &RBOUND THEN SET BAD = &BAD + 1
    ELSE +
         DO
             ISREDIT CHANGE P'=' &QT&NRSTR(&STRING)&QT &CL .ZCSR .ZCSR
             SET GOOD = &GOOD + 1
         END
    ISREDIT FIND NEXT P'=' 1 &VARIABLES
END

SET TOTAL = &GOOD + &BAD
SET ZEDLMSG = &STR(*** PROCESSED &GOOD OF &TOTAL 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 ATEND UTILITY +               02490000
                   *** NO PROCESSING PERFORMED ***)                     02490000
ISPEXEC SETMSG MSG(UTLZ000)                                             02490000
EXIT
            


Documentation

 This utility allows the user to place a given string at the end of each line
 which satisfies a specified edit criteria.  The "END" of a line is defined as
 the last non-blank character within the current editing "bounds".  For example,
 if you wanted to place a period (".") at the end of each "non-excluded" line,
 you would type => atend '.' nx <= on the command line, and a period would be
 placed in the first blank space following the last non-blank character in each
 non-excluded line.  You may specify edit criteria such as explicit line
 numbers; excluded status; label ranges; a combination of label ranges and
 excluded status; etc.            


Leave a Reply

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