Mainframe Utility: MISSING#

Return to Mainframe Utilities Page

Module


ISREDIT MACRO (COLUMN1,COLUMN2,OPT1,OPT2,OPT3,OPT4,OPT5,OPT6,OPT7,OPT8)
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
IF &STR(&COLUMN1) = HELP THEN GOTO HELPSEC
/**********************************************************************/
/* UTILITY NAME : MISSING#                                            */
/* AUTHOR       : DAVE LEIGH                                          */
/* DESCRIPTION  : ADD MESSAGE LINES WHERE A MISSING SEQUENCE NUMBER   */
/*              : SHOULD BE.                                          */
/**********************************************************************/

/**********************************************************************
/* SET SOME INITIAL VARIABLES.                                        *
/**********************************************************************
ISREDIT (LRECL) = LRECL
ISREDIT (LN,CL) = CURSOR
SET LINES_ADDED = 0
SET COUNTER_VALUE = 0
SET LINETYPE = MSGLINE
DO &I = 1 TO 8
    SET X = &&OPT&I
    SET X = &X
    IF &STR(&X) >      THEN +
        IF &STR(&X) = WRITE THEN SET LINETYPE = DATALINE
        ELSE SET OPTIONS = &STR(&OPTIONS &X)
END

/**********************************************************************
/* PARSE, VALIDATE THE USER'S INPUT                                   *
/**********************************************************************
IF &DATATYPE(&STR(&COLUMN1)) = CHAR OR +
   &DATATYPE(&STR(&COLUMN2)) = CHAR OR +
   &STR(&COLUMN1) = 0 OR +
   &STR(&COLUMN2) = 0 OR +
   &STR(&COLUMN1) =    OR +
   &STR(&COLUMN2) =    OR +
   &COLUMN2 < &COLUMN1 OR +
   &COLUMN1 > &LRECL OR +
   &COLUMN2 > &LRECL THEN +
    DO
        SET ZEDSMSG = &STR(INVALID PARAMETERS)
        SET ZEDLMSG = &STR(YOU MUST PASS A BEGINNING AND ENDING COLUMN +
                           # TO THE MISSING# MACRO (E.G. "MISSING# 35 +
                           40"))
        ISPEXEC SETMSG MSG(UTLZ001)
        EXIT CODE(12)
    END

/**********************************************************************
/* SET SOME MORE PROCESS VARIABLES.                                   *
/**********************************************************************
SET A1 =
SET A2 =
DO &I = 1 TO &EVAL(&COLUMN1 - 2)
    SET A1 = &STR(&A1>)
END
DO &I = &EVAL(&COLUMN2 - 2) TO &LRECL
    SET A2 = &STR(&A2<)
END
SET NUMLEN = &COLUMN2 - &COLUMN1 + 1

/**********************************************************************
/* GO THROUGH THE LINES SPECIFIED BY THE USER                         *
/**********************************************************************
ISREDIT FIND FIRST P'=' &STR(&OPTIONS)
DO WHILE &LASTCC = 0
    ISREDIT (LINE) = LINE .ZCSR
    SET NUMBER = &SUBSTR(&COLUMN1:&COLUMN2,&STR(&SYSNSUB(1,&LINE)))
    ERROR RETURN
    SET NUMBER = &NUMBER
    ERROR OFF
    IF &DATATYPE(&STR(&NUMBER)) = NUM THEN +
        IF &NUMBER > 0 THEN +
            IF &COUNTER_VALUE = 0 THEN +
                SET &COUNTER_VALUE = &NUMBER
            ELSE +
                DO
                    DO WHILE &EVAL(&NUMBER - &COUNTER_VALUE) > 1
                        SET COUNTER_VALUE = &COUNTER_VALUE + 1
                        SET X = &COUNTER_VALUE
                        SELECT
                            WHEN (&COUNTER_VALUE < 10) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 1)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 100) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 2)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 1000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 3)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 10000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 4)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 100000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 5)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 1000000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 6)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 10000000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 7)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 100000000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 8)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 1000000000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 9)
                                    SET X = &STR(0&X)
                                END
                            END
                            WHEN (&COUNTER_VALUE < 10000000000) DO
                                DO &I = 1 TO &EVAL(&NUMLEN - 10)
                                    SET X = &STR(0&X)
                                END
                            END
                            OTHERWISE DO
                                SET ZEDLMSG = &STR(THE NUMBER WIDTH +
                                                   IS TOO BIG TO HANDLE)
                                ISPEXEC SETMSG MSG(UTLZ001)
                                EXIT CODE(12)
                            END
                        END
                        SET LINES_ADDED = &LINES_ADDED + 1
                        ISREDIT LINE_BEFORE .ZCSR = &LINETYPE +
                                <1 (A1) (COLUMN1) (X) +
                                 &STR(&EVAL(&COLUMN2 + 2)) (A2)>
                    END
                    SET &COUNTER_VALUE = &NUMBER
                END
    ISREDIT FIND LAST P'=' .ZCSR .ZCSR
    ISREDIT FIND NEXT P'=' &STR(&OPTIONS)
END

/**********************************************************************
/* WRAP UP                                                            *
/**********************************************************************
IF &LINETYPE = DATALINE THEN +
    DO
        SET ZEDSMSG = &STR(&LINES_ADDED LINES INSERTED)
        SET ZEDLMSG = &STR(&LINES_ADDED SEQUENCE SKIPS FOUND.+
                           "F '<<<<<<' TO SEE INSERTED LINES)
    END
ELSE +
    DO
        SET ZEDSMSG = &STR(&LINES_ADDED SKIPS MARKED)
        SET ZEDLMSG = &STR(&LINES_ADDED SEQUENCE SKIPS FOUND.+
                           "L SPECIAL" TO SEE EACH ONE)
    END
ISPEXEC SETMSG MSG(UTLZ000)

ISREDIT CURSOR = &LN &CL

EXIT

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


Documentation


 MISSING# is an edit macro which helps you find missing numbers in a column
 which is supposed to have numbers in sequence.  For instance, if you are
 working on a document of some type where you have numbered bullets.  If those
 numbers are in a consistent column (right or left justified), MISSING# can tell
 you if you missed any numbers in your sequencing process.  If, for example, you
 numbered one item "23" and the next item "27" accidently, MISSING# would insert
 ISPF/PDF editor "message lines" before item "27" which told you that sequence
 numbers "24", "25", and "26" were missing.

 Syntax is as follows:

 COMMAND ===> missing# n1 n2 {other operands}

 "n1" is the beginning column of the number and "n2" is the ending column of the
 number.  "other operands" would be things like "x" or an edit label range to
 limit the processing.  The operands are optional and the whole file is
 processed if no operands are specified.
            


Leave a Reply

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