Mainframe Utility: PAGECONT

Return to Mainframe Utilities Page

Module


ISREDIT MACRO (PARM)
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(&PARM) = HELP THEN GOTO HELPSEC
/**********************************************************************
/* UTILITY : PAGECONT                                                 *
/* AUTHOR : DAVID LEIGH                                               *
/* DATE : 10-22-90                                                    *
/* FUNCTION : COUNT THE NUMBER OF LINES AND PAGES IN A FILE BEING     *
/*            EDITED WHICH HAS ANSI CONTROL CHARACTERS IN COLUMN 1.   *
/**********************************************************************

SET ZEDLMSG = &STR(*** COUNTING PAGES AND LINES ***)
ISPEXEC CONTROL DISPLAY LOCK
ISPEXEC DISPLAY MSG(UTLZ000W)

ISREDIT (LN,CL) = CURSOR
FREE DDNAME(TEMPDD)
DELETE TEMP.PAGECONT
ALLOC DD(TEMPDD) DSN(TEMP.PAGECONT) +
                 NEW CATALOG +
                 UNIT(SYSDA) VOLUME(WRK$$$) +
                 SPACE(2,2) TRACKS RELEASE +
                 RECFM(F B) LRECL(80) BLKSIZE(23440) DSORG(PS)
OPENFILE TEMPDD OUTPUT

SET PAGE = 0
SET LINE = 0
SET BAD  = 0
ISREDIT FIND FIRST P'=' 1
DO WHILE &LASTCC = 0
    ISREDIT (COL) = LINE .ZCSR
    SET COL = &SUBSTR(1:1,&NRSTR(&COL))
    SELECT (&STR(&COL))
        WHEN (&STR( )) SET LINE = &LINE + 1
        WHEN (&STR(0)) SET LINE = &LINE + 2
        WHEN (&STR(-)) SET LINE = &LINE + 3
        WHEN (&STR(+)) SET LINE = &LINE
        WHEN (&STR(1)) +
            DO
                SET PAGE = &PAGE + 1
                SET TEMPDD = &STR(PAGE &PAGE CONTAINS &LINE LINES)
                PUTFILE TEMPDD
                SET LINE = 1
                SET ZEDLMSG = &STR(*** &PAGE PAGES COUNTED SO FAR ***)
                ISPEXEC CONTROL DISPLAY LOCK
                ISPEXEC DISPLAY MSG(UTLZ000W)
            END
        OTHERWISE +
            DO
                SET BAD = &BAD + 1
                SET LINE = &LINE + 1
            END
    END
    ISREDIT FIND NEXT P'=' 1
END

IF &LINE > 0 THEN +
    DO
        SET PAGE = &PAGE + 1
        SET TEMPDD = &STR(PAGE &PAGE CONTAINS &LINE LINES)
        PUTFILE TEMPDD
        SET ZEDLMSG = &STR(*** &PAGE PAGES COUNTED SO FAR ***)
        ISPEXEC CONTROL DISPLAY LOCK
        ISPEXEC DISPLAY MSG(UTLZ000W)
    END

IF &BAD > 0 THEN +
    DO
        SET TEMPDD = &STR(&BAD LINES DID NOT CONTAIN VALID ANSI +
                          CONTROL CHARACTERS)
        PUTFILE TEMPDD
        SET TEMPDD = &STR(THEY WERE COUNTED AS " " CONTROL CHARACTERS)
        PUTFILE TEMPDD
    END

CLOSFILE TEMPDD
FREE DDNAME(TEMPDD)
ISPEXEC EDIT DATASET(TEMP.PAGECONT)

ISREDIT CURSOR = &LN &CL

EXIT

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


Documentation


 The PAGECONT EDIT MACRO counts the number of pages and number of lines in each
 page in a file which has ANSI control characters in column 1.  It then takes
 the user in to an edit of a "results" file where the number of lines in each
 page is listed.

 This can be a good tool to see if your document has any pages which need to be
 broken up so as to page break properly.

 See the PAGINATE Edit Macro for more information on re-paginating documents
 with ANSI control characters.
            


Leave a Reply

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