Mainframe Utility: PASTE

Return to Mainframe Utilities Page

Module


         /*********************************************************/
         /*   ISPF/PDF EDIT MACRO TO WRITE LINES FROM A ISPF      */
         /*   ISPF TABLE INTO THE CURRENT FILE.                   */
         /*   THIS MACRO IS USED IN CONJUNCTION WITH THE CUT      */
         /*   CUT MACRO                                           */
         /*                                                       */
         /*   SUPPORT                                             */
         /*    STEVEN SMITH SECURITY PACIFIC AUTOMATION CO OCT 88 */
         /*                                                       */
         /*   FOR HELP ON RUNNING THIS MACRO, UNDER EDIT ENTER:   */
         /*     PASTE HELP                                        */
         /*********************************************************/

           ISREDIT MACRO (PARM1 PARM2 PARM3 PARM4) 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
         IF &LENGTH(&STR(&PARM1)) = 2 AND +
            &SYSINDEX(&STR(.),&STR(&PARM1)) = 0 THEN +
             SET CT = &STR(&PARM1)
         ELSE +
             SELECT (&SYSCAPS(&STR(&PARM1)))
                 WHEN (B ¦ BE ¦ BEF ¦ BEFO ¦ BEFOR ¦ BEFORE) +
                     SET BEFAFT = BEFORE
                 WHEN (A ¦ AF ¦ AFT ¦ AFTE ¦ AFTER ) +
                     SET BEFAFT = AFTER
                 WHEN (H ¦ HE ¦ HEL ¦ HELP) +
                     SET ACTN = HELP
                 WHEN (P ¦ PR ¦ PRO ¦ PROM ¦ PROMP ¦ PROMPT) +
                     SET ACTN = PROMPT
                 WHEN (D ¦ DE ¦ DEF ¦ DEFA ¦ DEFAU ¦ DEFAUL +
                       DEFAULT ¦ DEFAULTS) +
                     SET ACTN = DEFAULTS
                 WHEN (Z ¦ ZE ¦ ZER ¦ ZERO) +
                     SET ACTN = ZERO
                 OTHERWISE DO
                     SET X = &LENGTH(&STR(&PARM1))
                     IF &X > 1 THEN +
                         DO
                             SET POINT = &SUBSTR(1:1,&STR(&PARM1))
                             SET LABEL = &SUBSTR(2:&X,&STR(&PARM1))
                             IF &STR(&POINT) ¬= &STR(.) AND +
                                &DATATYPE(&PARM1) = CHAR THEN +
                                 DO
                                     SET ZEDLMSG = &STR("&PARM1" IS +
                                         NOT A VALID PARAMETER)
                                     ISPEXEC SETMSG MSG(UTLZ001)
                                     EXIT CODE(12)
                                 END
                             ELSE SET LABEL = &STR(&PARM1)
                         END
                 END
             END
         IF &LENGTH(&STR(&PARM2)) = 2 AND +
            &SYSINDEX(&STR(.),&STR(&PARM2)) = 0 THEN +
             SET CT = &STR(&PARM2)
         ELSE +
             SELECT (&SYSCAPS(&STR(&PARM2)))
                 WHEN (B ¦ BE ¦ BEF ¦ BEFO ¦ BEFOR ¦ BEFORE) +
                     SET BEFAFT = BEFORE
                 WHEN (A ¦ AF ¦ AFT ¦ AFTE ¦ AFTER ) +
                     SET BEFAFT = AFTER
                 WHEN (H ¦ HE ¦ HEL ¦ HELP) +
                     SET ACTN = HELP
                 WHEN (P ¦ PR ¦ PRO ¦ PROM ¦ PROMP ¦ PROMPT) +
                     SET ACTN = PROMPT
                 WHEN (D ¦ DE ¦ DEF ¦ DEFA ¦ DEFAU ¦ DEFAUL +
                       DEFAULT ¦ DEFAULTS) +
                     SET ACTN = DEFAULTS
                 WHEN (Z ¦ ZE ¦ ZER ¦ ZERO) +
                     SET ACTN = ZERO
                 OTHERWISE DO
                     SET X = &LENGTH(&STR(&PARM2))
                     IF &X > 1 THEN +
                         DO
                             SET POINT = &SUBSTR(1:1,&STR(&PARM2))
                             SET LABEL = &SUBSTR(2:&X,&STR(&PARM2))
                             IF &STR(&POINT) ¬= &STR(.) AND +
                                &DATATYPE(&PARM2) = CHAR THEN +
                                 DO
                                     SET ZEDLMSG = &STR("&PARM2" IS +
                                         NOT A VALID PARAMETER)
                                     ISPEXEC SETMSG MSG(UTLZ001)
                                     EXIT CODE(12)
                                 END
                             ELSE SET LABEL = &STR(&PARM2)
                         END
                 END
             END
         IF &LENGTH(&STR(&PARM3)) = 2 AND +
            &SYSINDEX(&STR(.),&STR(&PARM3)) = 0 THEN +
             SET CT = &STR(&PARM3)
         ELSE +
             SELECT (&SYSCAPS(&STR(&PARM3)))
                 WHEN (B ¦ BE ¦ BEF ¦ BEFO ¦ BEFOR ¦ BEFORE) +
                     SET BEFAFT = BEFORE
                 WHEN (A ¦ AF ¦ AFT ¦ AFTE ¦ AFTER ) +
                     SET BEFAFT = AFTER
                 WHEN (H ¦ HE ¦ HEL ¦ HELP) +
                     SET ACTN = HELP
                 WHEN (P ¦ PR ¦ PRO ¦ PROM ¦ PROMP ¦ PROMPT) +
                     SET ACTN = PROMPT
                 WHEN (D ¦ DE ¦ DEF ¦ DEFA ¦ DEFAU ¦ DEFAUL +
                       DEFAULT ¦ DEFAULTS) +
                     SET ACTN = DEFAULTS
                 WHEN (Z ¦ ZE ¦ ZER ¦ ZERO) +
                     SET ACTN = ZERO
                 OTHERWISE DO
                     SET X = &LENGTH(&STR(&PARM3))
                     IF &X > 1 THEN +
                         DO
                             SET POINT = &SUBSTR(1:1,&STR(&PARM3))
                             SET LABEL = &SUBSTR(2:&X,&STR(&PARM3))
                             IF &STR(&POINT) ¬= &STR(.) AND +
                                &DATATYPE(&PARM3) = CHAR THEN +
                                 DO
                                     SET ZEDLMSG = &STR("&PARM3" IS +
                                         NOT A VALID PARAMETER)
                                     ISPEXEC SETMSG MSG(UTLZ001)
                                     EXIT CODE(12)
                                 END
                             ELSE SET LABEL = &STR(&PARM3)
                         END
                 END
             END
         IF &LENGTH(&STR(&PARM4)) = 2 AND +
            &SYSINDEX(&STR(.),&STR(&PARM4)) = 0 THEN +
             SET CT = &STR(&PARM4)
         ELSE +
             SELECT (&SYSCAPS(&STR(&PARM4)))
                 WHEN (B ¦ BE ¦ BEF ¦ BEFO ¦ BEFOR ¦ BEFORE) +
                     SET BEFAFT = BEFORE
                 WHEN (A ¦ AF ¦ AFT ¦ AFTE ¦ AFTER ) +
                     SET BEFAFT = AFTER
                 WHEN (H ¦ HE ¦ HEL ¦ HELP) +
                     SET ACTN = HELP
                 WHEN (P ¦ PR ¦ PRO ¦ PROM ¦ PROMP ¦ PROMPT) +
                     SET ACTN = PROMPT
                 WHEN (D ¦ DE ¦ DEF ¦ DEFA ¦ DEFAU ¦ DEFAUL +
                       DEFAULT ¦ DEFAULTS) +
                     SET ACTN = DEFAULTS
                 WHEN (Z ¦ ZE ¦ ZER ¦ ZERO) +
                     SET ACTN = ZERO
                 OTHERWISE DO
                     SET X = &LENGTH(&STR(&PARM4))
                     IF &X > 1 THEN +
                         DO
                             SET POINT = &SUBSTR(1:1,&STR(&PARM4))
                             SET LABEL = &SUBSTR(2:&X,&STR(&PARM4))
                             IF &STR(&POINT) ¬= &STR(.) AND +
                                &DATATYPE(&PARM4) = CHAR THEN +
                                 DO
                                     SET ZEDLMSG = &STR("&PARM4" IS +
                                         NOT A VALID PARAMETER)
                                     ISPEXEC SETMSG MSG(UTLZ001)
                                     EXIT CODE(12)
                                 END
                             ELSE SET LABEL = &STR(&PARM4)
                         END
                 END
             END
         VERIFY: -
         ISPEXEC CONTROL NONDISPL
         PROMPT: -
         ISPEXEC DISPLAY PANEL(PASTEPRM)
         IF &LASTCC=8 THEN EXIT CODE(0)
         IF &ACTN = HELP THEN +
          DO
         /*ISPEXEC BROWSE DATASET('SYS6.DOC.DATA(PASTE)')
           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(PASTEDEF)
         IF &LASTCC=8 THEN EXIT CODE(0)
         IF &ACTN = &Z THEN SET ACTN=&PASTEDEF
IF &STR(&BEFAFT) = BEFORE OR +
   &STR(&BEFAFT) = AFTER  THEN +
    GOTO AFTER_PROCS
         /* PROCESS LINE COMMANDS, CHECK IF A OR B WAS SPECIFIED */
PROCS: -
         ISREDIT PROCESS DEST
         SET RC = &LASTCC
         IF &RC >= 16 THEN EXIT CODE(12)
         ELSE +
          IF &RC >= 4 THEN +
          DO
            SET ZEDSMSG = ENTER "A"¦"B" LINE CMD
            SET ZEDLMSG = PASTE REQUIRES AN "A" OR "B" LINE COMMAND
            ISPEXEC SETMSG MSG(ISRZ001)
            EXIT CODE(12)
          END

      /*  CONTROL LIST CONLIST SYMLIST
AFTER_PROCS: -
          ISPEXEC CONTROL ERRORS RETURN
         /* GET THE NUMBER OF LINES VARIABLE */
         SET CUTPST=CUTPST&CT
         ISPEXEC TBQUERY &CUTPST ROWNUM(CUTCNT)
         IF &LASTCC ¬= 0 THEN DO
            ISPEXEC TBCREATE &CUTPST NAMES(CTPT) NOWRITE SHARE
            IF &LASTCC = 0 THEN DO
             SET ZEDSMSG = USE CUT BEFORE PASTE
             SET ZEDLMSG = THE CUTCNT PROFILE VARIABLE WAS NOT FOUND
             SET ZEDLMSG = &ZEDLMST &STR(-) USE CUT FIRST
             ISPEXEC SETMSG MSG(ISRZ001)
             EXIT CODE(12)
            END
            ELSE DO
              ISPEXEC TBOPEN &CUTPST NOWRITE SHARE
              IF &LASTCC ¬= 0 THEN DO
                  EXIT CODE(12)
              END
              ISPEXEC TBQUERY &CUTPST ROWNUM(CUTCNT)
            END
        END
         IF &CUTCNT <= 0 THEN +
           DO
             SET ZEDSMSG = USE CUT BEFORE PASTE
             SET ZEDLMSG = NO DATA HAS BEEN STORED VIA THE CUT MACRO
             ISPEXEC SETMSG MSG(ISRZ001)
             EXIT CODE(12)
           END

         IF &STR(&BEFAFT) >      THEN +
             IF &DATATYPE(&LABEL) = NUM THEN +
                 DO
                     SET ZDEST = &LABEL
                     ISREDIT CURSOR = &LABEL 9
                     IF &STR(&BEFAFT) = BEFORE THEN +
                         DO
                             ISREDIT FIND PREV P'=' 10
                             SET BEFAFT = AFTER
                         END
                     SET LABEL = &STR(.ZCSR)
                 END
             ELSE +
                 DO
                     IF &STR(&BEFAFT) = BEFORE THEN +
                         DO
                             ISREDIT FIND FIRST P'=' 10 &LABEL &LABEL
                             ISREDIT FIND PREV P'=' 10
                             SET BEFAFT = AFTER
                             SET LABEL = &STR(.ZCSR)
                         END
                     ISREDIT (ZDEST) = LINENUM &LABEL
                 END
         ELSE +
             ISREDIT (ZDEST) = LINENUM .ZDEST
         SET TRUNCCNT = 0
         SET CUTCOUNT = &CUTCNT
         /* GET EACH CUT LINE FROM THE TABLE AND ADD IT TO THE FILE */
         SET I = &CUTCNT
         ISPEXEC TBBOTTOM &CUTPST
         DO WHILE &I > 0
           IF &STR(&BEFAFT) >      THEN +
               ISREDIT LINE_&BEFAFT &LABEL = DATALINE (CTPT)
           ELSE +
               ISREDIT LINE_AFTER &ZDEST = DATALINE (CTPT)
           IF &LASTCC = 4 THEN SET TRUNCCNT = &TRUNCCNT + 1
           ISPEXEC TBSKIP &CUTPST NUMBER(-1)
           SET I = &I - 1
         END


         /* IF KEEP PARAMETER NOT GIVEN AND NO LINES WERE TRUNCATED, */
         /* SET TO NULL ALL VARIABLES STORED IN THE PROFILE.         */
         IF &ACTN=ZERO THEN +
           DO
              SET &LCC=0
              ISPEXEC TBBOTTOM &CUTPST
              DO WHILE &LCC=0
                 ISPEXEC TBDELETE &CUTPST
                 SET LCC=&LASTCC
             END
           END

         /* CHECK IF TRUNCATION OCCURRED, IF SO DISPLAY MESSAGE */
         IF &TRUNCCNT > 0 THEN +
           DO
             SET ZEDSMSG = &TRUNCCNT LINES TRUNCATED
             SET ZEDLMSG = CURRENT RECORD LENGTH SHORTER THAN ORIGIN
             SET ZEDLMSG = &ZEDLMSG &STR(-) &TRUNCCNT OF &CUTCOUNT
             SET ZEDLMSG = &STR(&ZEDLMSG) RECORDS WERE TRUNCATED
             ISPEXEC SETMSG MSG(ISRZ001)
           END
         ELSE +
           DO
             SET ZEDSMSG = &CUTCOUNT LINES PASTED
             SET ZEDLMSG = &CUTCOUNT LINES WERE PASTED INTO THE
             SET ZEDLMSG = &ZEDLMSG CURRENT FILE
             ISPEXEC SETMSG MSG(ISRZ000)
           END

         SET LINE1 = &ZDEST + 1
         ISREDIT CURSOR = &LINE1 0
         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

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