Mainframe Utility: CUT

Return to Mainframe Utilities Page

Module


         /*********************************************************/
         /*   ISPF/PDF EDIT MACRO TO WRITE LINES FROM A FILE TO A */
         /*   ISPF TABLE IN MEMBER FOR LATTER INCLUSION BY THE    */
         /*   PASTE MACRO.                                        */
         /*                                                       */
         /*   SUPPORT                                             */
         /*    STEVEN SMITH SECURITY PACIFIC AUTOMATION CO OCT 88 */
         /*                                                       */
         /*   FOR HELP ON RUNNING THIS MACRO, UNDER EDIT ENTER:   */
         /*       CUT HELP                                        */
         /*********************************************************/
         ISREDIT MACRO (PARM1 PARM2 PARM3) NOPROCESS
/*** CHECK THE DEBUG SWITCH ***/
ISPEXEC VGET DBGSWTCH PROFILE
IF &DBGSWTCH = ON THEN +
    CONTROL MSG LIST CONLIST SYMLIST NOFLUSH NOPROMPT ASIS
ELSE +
    CONTROL NOMSG NOLIST NOFLUSH NOPROMPT ASIS

         /* CONTROL LIST CONLIST SYMLIST
         ISPEXEC CONTROL ERRORS RETURN
         ISPEXEC VGET (CUTDEF PASTEDEF CUTLIMIT CUTNAME) PROFILE
         SET ACTN=&Z
         SET CT=&Z
         SET CUTCOUNT=&Z
         IF &STR(&PARM1)=&Z THEN GOTO VERIFY
         IF &LENGTH(&STR(&PARM1))=2 THEN SET CT=&PARM1
           ELSE IF &DATATYPE(&PARM1) = NUM THEN SET CUTCOUNT=&PARM1
             ELSE SET ACTN=&PARM1
         IF &STR(&PARM2)=&Z THEN GOTO VERIFY
         IF &LENGTH(&STR(&PARM2))=2 THEN SET CT=&PARM2
           ELSE IF &DATATYPE(&PARM2) = NUM THEN SET CUTCOUNT=&PARM2
             ELSE SET ACTN=&PARM2
         IF &STR(&PARM3)=&Z THEN GOTO VERIFY
         IF &LENGTH(&STR(&PARM3))=2 THEN SET CT=&PARM3
           ELSE IF &DATATYPE(&PARM3) = NUM THEN SET CUTCOUNT=&PARM3
             ELSE SET ACTN=&PARM3
         VERIFY: -
         ISPEXEC CONTROL NONDISPL
         PROMPT: -
         ISPEXEC DISPLAY PANEL(CUTPROM)
         IF &LASTCC>7 THEN EXIT CODE(0)
         IF &ACTN = HELP THEN +
          DO
         /*ISPEXEC BROWSE DATASET('SYS6.DOC.DATA(CUT)')
           ISPEXEC SELECT PGM(ISPTUTOR) PARM(CUTHELP@)
           SET ACTN=&Z
           GOTO PROMPT
          END
         IF &ACTN=PROMPT THEN +
          DO
           SET ACTN=&Z
           GOTO PROMPT
          END
         /* GET DEFAULT MODE */
         DEFAULT: -
         IF &ACTN=DEFAULTS THEN SET ACTN=&Z
         ELSE ISPEXEC CONTROL NONDISPL
         ISPEXEC DISPLAY PANEL(CUTDEF)
         IF &LASTCC>7 THEN EXIT CODE(0)
         IF &ACTN = &Z THEN SET ACTN=&CUTDEF
         GOTO PROCS
         /* PROCESS LINE COMMANDS, CHECK IF C OR M WAS SPECIFIED */
         PROCS: -
         ISREDIT PROCESS RANGE C M
         IF &LASTCC >= 16 THEN DO
              EXIT CODE(12)
              END
         ELSE +
           IF &LASTCC >= 4 THEN +
              DO
              SET ZEDSMSG = ENTER "C" ¦ "M" LINE CMD
              SET ZEDLMSG = CUT REQUIRES A "C" OR "M" LINE COMMAND
              ISPEXEC SETMSG MSG(ISRZ001)
              EXIT CODE(12)
              END

         ISREDIT (CMD) = RANGE_CMD            /* GET THE COMMAND     */
         ISREDIT (LINE1) = LINENUM .ZFRANGE   /* FIRST LINE IN RANGE */
         ISREDIT (LINE2) = LINENUM .ZLRANGE   /* LAST LINE IN RANGE  */
         SET LINESTOCUT = &LINE2 - &LINE1 + 1

         /* GET THE NUM OF LINES THAT HAVE BEEN CUT BUT NOT PASTED,  */
         /* INITIALIZE TO ZERO IF FIRST TIME.                        */
         SET CUTPST=CUTPST&CT
         ISPEXEC TBQUERY &CUTPST ROWNUM(CUTCNTMX)
         IF &LASTCC ¬= 0 THEN DO
            ISPEXEC TBCREATE &CUTPST  NAMES(CTPT) NOWRITE SHARE
            IF &LASTCC ¬= 0 THEN DO
                ISPEXEC TBOPEN &CUTPST NOWRITE SHARE
                IF &LASTCC ¬= 0 THEN DO
                   EXIT CODE(12)
                END
            END
            SET CUTCNTMX=0
         END

         ISPEXEC TBBOTTOM &CUTPST
         IF &ACTN=REPLACE THEN +
            DO
               SET &LCC=0
               DO WHILE &LCC=0
                   ISPEXEC TBDELETE &CUTPST
                   SET LCC=&LASTCC
               END
                  SET CUTCNTMX = 0
            END
         SET CUTCNTMXSAVE = &CUTCNTMX

         /* CHECK TO SEE IF THE LIMIT WILL BE EXCEEDED BY STORING   */
         /* THE LINES                                               */
         SET COUNT = &CUTCNTMX + &LINESTOCUT
         IF &COUNT > &CUTCOUNT THEN DO
         SET ZEDSMSG = > &CUTCOUNT LINES TO CUT
         SET ZEDLMSG=REDUCE THE RANGE OR CHANGE LIMIT WITH "CUT &COUNT"
         ISPEXEC SETMSG MSG(ISRZ001)
         EXIT CODE(12)
         END

         /* CUT THE LINES TO THE TABLE */
         SET CUTCNT = &CUTCNTMX
         SET I = &LINE1
         DO WHILE &I <= &LINE2
           SET CUTCNT = &CUTCNT + 1
           ISREDIT (CTPT) = LINE &I
           ISPEXEC TBADD &CUTPST
           SET I = &I + 1
         END



         /* IF THE NUMBER OF LINES CUT THIS TIME
         /* IS GREATER THAN THE MAXIMUM CUT,
         /* THEN SAVE THE NEW MAXIMUM.
         /* PASTE WILL SET THIS VARIABLE TO
         /* ZERO IF IT DELETES THE VARIABLES.
         IF &CMD = M THEN DO
             ISREDIT DELETE &LINE1 &LINE2
             IF &CUTCNTMXSAVE = 0 THEN +
              DO
              SET ZEDSMSG = &LINESTOCUT LINES CUT AND DELETED
              SET ZEDLMSG = &LINESTOCUT LINES WERE CUT AND
              SET ZEDLMSG = &ZEDLMSG DELETED FROM THE CURRENT FILE
              END
             ELSE +
              DO
              SET ZEDSMSG = &LINESTOCUT LINES CUT AND DELETED'
              SET ZEDLMSG = A TOTAL OF &CUTCNTMX LINES HAVE BEEN CUT
              SET ZEDLMSG = &ZEDLMSG, THE LAST &LINESTOCUT WERE DELETED
              END
             ISPEXEC SETMSG MSG(ISRZ000)
           END
         ELSE +
             DO
             IF &CUTCNTMXSAVE = 0 THEN +
              DO
              SET ZEDSMSG = &LINESTOCUT LINES CUT
              SET ZEDLMSG = &LINESTOCUT LINES WERE CUT
              SET ZEDLMSG = &ZEDLMSG FROM THE CURRENT FILE
              END
             ELSE +
              DO
              SET ZEDSMSG = &LINESTOCUT LINES PLUS &CUTCNTMXSAVE LINES
              SET ZEDSMSG = &ZEDSMSG CUT
              SET ZEDLMSG = A TOTAL OF &CUTCNTMX LINES HAVE BEEN CUT
              END
             ISPEXEC  SETMSG MSG(ISRZ000)
           END

         EXIT

            


Documentation


 The CUT and PASTE edit macros provide a handy method to move data from one edit
 session to another.  The CUT macro saves lines from an edit session.  The PASTE
 macro places these lines into another edit session (or the same session).  The
 CUT macro can combine lines with previously saved lines.  The PASTE macro
 places these lines into one or more edit session.  The edit sessions can be on
 different screens and/or edit sessions started at a later time provided the
 user does not exit ISPF.

 The CUT and PASTE macros have several optional operands.  The operands P (or
 PROMPT) and D (or DEFAULTS) provide menu panels for entering the optional
 operands as shown in the screen layouts below.  The operand H (or HELP) can be
 used to provide tutorial panels.  The lines from the CUT macro are saved in an
 ISPF table.  A two-character operand is used to name the table for saved lines.
 A numeric operand sets the limit for the size of the table.  A two-character
 operand on the PASTE macro names the table to obtain the lines.  A numeric
 operand is not used with PASTE.  The table name will default if not given.
 This default can be changed.

 OPERAND      FUNCTION

 action       This is the action to be performed by this CUT operation.  Valid
              choices are ADD to lines already cut or REPLACE the lines already
              cut with the new lines.  HELP is used to enter the tutorial for
              CUT and PASTE.  DEF is used to display the defaults panel for CUT.
              If no operands are entered on the command, the defaults are used.

 table        This specifies a two-character suffix for the ISPF table
              generated.  The table name prefix is CUTPST.  This operand can be
              used to create several different groups of lines for later use by
              PASTE.

 limit        The maximum number of lines to be cut by this operation.  This
              number can be from 100 to 99999.

 Identify the lines to be cut by using the C, CC, M, or MM line commands in the
 edit session.

 OPERAND      FUNCTION

 action       This is the action to be performed by this PASTE operation.  Valid
              choices are KEEP the lines cut in the ISPF table or ZERO the lines
              cut so future CUT actions will start with an empty table.  HELP is
              used to enter the tutorial for CUT and PASTE.  DEF is used to
              display the defaults panel for PASTE.  If no operands are entered
              on the command, the defaults are used.

 table        This operand specifies the suffix of the ISPF table that has the
              lines to be pasted.  This name, if different from the default
              name, must have been created by a prior CUT command.

 Identify where the lines are to be placed using the A or B edit line commands.

 Notes:

 1.  All operands on both commands are optional.  The defaults values are used
     for any item not entered.

 2.  The data lines cut are kept in an ISPF table.  ISPF tables are associated
     with a logical screen.  If the screen where the lines were CUT is ended,
     the table is deleted and the lines are not available for use by PASTE.  A
     logical screen is created by the SPLIT or HOLD commands.  The lines are
     also deleted when the ISPF session is terminated.  They are not saved
     across ISPF sessions.

 ------------------------- CUT prompt and set defaults ------------------------
 COMMAND ===>

 Action       ====>           ADD, REPLACE, or blank for default
     Enter  END key for no action
 CUT table name===>           any two character name for this one time
                              blank for default
 CUT size limit===> 5000      any number 100 to 99999 for this one time

 Set default actions for CUT and PASTE

 CUT default   ===> ADD       ADD or REPLACE
 PASTE default ===> KEEP      KEEP or ZERO
 CUT table name===> DF        any two character name for default
 CUT size limit===> 5000      any number 100 to 99999 for default

   ADD adds CUT lines to the end of previously CUT lines, if any
   REPLACE clears any previously CUT lines and replaces them with newly CUT
           lines
   ZERO deletes previously CUT lines after the PASTE operation
   KEEP keeps previously CUT lines after the PASTE operation to be used by a
        later PASTE or added to by later CUT operations

 ------------------------ PASTE prompt and set defaults -----------------------
 COMMAND ===>

 Action       ====>           ZERO, KEEP, or blank for default
     Enter  END key for no action
 CUT table name===>           any two character name for this one time
                              blank for default

 Set default actions for CUT and PASTE

 CUT default   ===> ADD       ADD or REPLACE
 PASTE default ===> KEEP      KEEP or ZERO
 CUT table name===> DF        any two character name for default
 CUT size limit===> 5000      any number 100 to 99999 for default

   ADD adds CUT lines to the end of previously CUT lines, if any
   REPLACE clears any previously CUT lines and replaces them with newly CUT
           lines
   ZERO deletes previously CUT lines after the PASTE operation
   KEEP keeps previously CUT lines after the PASTE operation to be used by a
        later PASTE or added to by later CUT operations
            


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.