Mainframe Utility: LONGEST

Return to Mainframe Utilities Page

Module


ISREDIT MACRO (OPT1,OPT2,OPT3,OPT4,OPT5)
ISPEXEC CONTROL ERRORS RETURN
ISPEXEC VGET (DBGSWTCH) PROFILE
IF &DBGSWTCH = &STR(ON) THEN +
     CONTROL MSG LIST CONLIST SYMLIST NOFLUSH
ELSE CONTROL NOMSG NOLIST NOFLUSH NOPROMPT
IF &STR(&OPT1) = HELP THEN GOTO HELPSEC
/**********************************************************************
/* EDIT MACRO : LONGEST                                               *
/* AUTHOR     : DAVID LEIGH                                           *
/* FUNCTION   : DETERMINE THE LONGEST LINE IN THE FILE.               *
/**********************************************************************

SET OPTIONS = &STR(&OPT1 &OPT2 &OPT3 &OPT4 &OPT5)
SET X = 0
ISREDIT FIND FIRST P'=' 1 &STR(&OPTIONS)
DO WHILE &LASTCC = 0
    ISREDIT FIND LAST P'¬' .ZCSR .ZCSR
    ISREDIT (LN,CL) = CURSOR
    IF &CL > &X THEN +
        DO
            SET X = &CL
            SET LINE = &LN
        END
    ISREDIT FIND NEXT P'=' 1 &STR(&OPTIONS)
END

ISREDIT CURSOR = &LINE 1
SET MSG1 = &STR(THE NEXT LINE IS THE LONGEST IN THIS FILE.)
SET MSG2 = &STR(THE LAST NON-BLANK BYTE IS IN COLUMN: &X)
SET MSG3 = &STR(/ / / / / / / / / / / / / /)
ISREDIT LINE_BEFORE .ZCSR = MSGLINE (MSG1)
ISREDIT LINE_BEFORE .ZCSR = MSGLINE (MSG2)
ISREDIT UP 2
ISREDIT LINE_AFTER .ZCSR = MSGLINE (MSG3)

EXIT

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


Documentation


 The LONGEST edit macro will place message lines around the longest text line in
 the file being edited.  You simply type LONGEST on the command line and press
 .  LONGEST then searches through the file and finds the last non-blank
 byte on every line.   When it has gone through the file, it marks the line in
 which the last non-blank byte is the farthest out.  It marks it with ISPF/PDF
 editor "message" lines and it indicates which byte contains the last non-blank
 character on the line.  You are positioned to the longest line as well.
            


Leave a Reply

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