Mainframe Utility: MISSINGnum

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. &quot;MISSING# 35 +
                           40&quot;))
        ISPEXEC SETMSG MSG(UTLZ001)
        EXIT CODE(12)
    END
&nbsp;
/**********************************************************************
/* 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"> 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>
                    END
                    SET &COUNTER_VALUE = &NUMBER
                END
    ISREDIT FIND LAST P'=' .ZCSR .ZCSR
    ISREDIT FIND NEXT P'=' &STR(&OPTIONS)
END
&nbsp;
/**********************************************************************
/* WRAP UP                                                            *
/**********************************************************************
IF &LINETYPE = DATALINE THEN +
    DO
        SET ZEDSMSG = &STR(&LINES_ADDED LINES INSERTED)
        SET ZEDLMSG = &STR(&LINES_ADDED SEQUENCE SKIPS FOUND.+
                           &quot;F '<<<<<<' to see inserted lines>            


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 &quot;23&quot; and the next item &quot;27&quot; accidently, MISSING# would insert
 ISPF/PDF editor &quot;message lines&quot; before item &quot;27&quot; which told you that sequence
 numbers &quot;24&quot;, &quot;25&quot;, and &quot;26&quot; were missing.
&nbsp;
 Syntax is as follows:
&nbsp;
 COMMAND ===> missing# n1 n2 {other operands}
&nbsp;
 &quot;n1&quot; is the beginning column of the number and &quot;n2&quot; is the ending column of the
 number.  &quot;other operands&quot; would be things like &quot;x&quot; 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 *