Mainframe Utility: ECHANGE

Return to Mainframe Utilities Page

Module


/**********************************************************************
/* UTILITY: ECHANGE                                                   *
/* AUTHOR: DAVID LEIGH                                                *
/* FUNCTION: THIS UTILITY PROVIDES A WAY TO CHANGE EXTRA LONG STRINGS *
/*           WITHOUT HAVING TO WRITE A MACRO OR SET KEYS.  IT ALSO    *
/*           AUTOMATICALLY PARSES FOR A SPACE DELIMITED WORD IF YOUR  *
/*           CURSOR IS IN THE DATA.  THAT BECOMES THE "FROM" STRING.  *
/**********************************************************************
ISREDIT MACRO (PARM1 PARM2)
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 ASIS
ELSE +
    CONTROL NOMSG NOLIST NOFLUSH NOPROMPT ASIS
IF &STR(&SYSNSUB(1,&PARM)) = HELP THEN GOTO HELPSEC

/**********************************************************************
/* EVALUATE ANY PASSED PARMS                                          *
/**********************************************************************
SET QT = &STR(')
SELECT (&SYSCAPS(&PARM1))
    WHEN (PREFIX) SET PREFIX = &STR(&SYSNSUB(1,&PARM2))
    WHEN (SUFFIX) SET SUFFIX = &STR(&SYSNSUB(1,&PARM2))
    WHEN (TO)     SET CTO    = &STR(&QT&SYSNSUB(1,&PARM2)&QT)
END

/**********************************************************************
/* SAVE THE CURSOR POSITION AND SEE IF WE'RE ON THE COMMAND LINE      *
/**********************************************************************
ISREDIT (LN,CL) = CURSOR
IF &CL = 0 THEN GOTO DISPLAY

/**********************************************************************
/* IF NOT ON THE COMMAND LINE FIND THE STRING OUR CURSOR IS ON        *
/**********************************************************************
ISREDIT FIND PREV ' ' .ZCSR .ZCSR
ISREDIT FIND NEXT P'¬' .ZCSR .ZCSR
ISREDIT (LN1,CL1) = CURSOR
ISREDIT FIND NEXT ' ' .ZCSR .ZCSR
ISREDIT FIND PREV P'¬' .ZCSR .ZCSR
ISREDIT (LN2,CL2) = CURSOR
ISREDIT (CFROM) = LINE .ZCSR
SET CFROM = &SUBSTR(&CL1:&CL2,&STR(&SYSNSUB(1,&CFROM)))
IF &SYSINDEX(&STR('),&STR(&SYSNSUB(1,&CFROM))) > 0 AND +
   &SYSINDEX(&STR("),&STR(&SYSNSUB(1,&CFROM))) = 0 THEN +
    SET QT = &STR(")
IF &STR(&SYSNSUB(1,&CTO)) =       THEN +
    SET CTO   = &STR(&QT&SYSNSUB(1,&PREFIX)+
                      &SYSNSUB(1,&CFROM)+
                      &SYSNSUB(1,&SUFFIX)&QT)
SET CFROM = &STR(&QT&SYSNSUB(1,&CFROM)&QT)

/**********************************************************************
/* DISPLAY THE DATA ENTRY PANEL AND EXIT IF THE USER "END"S OUT       *
/**********************************************************************
DISPLAY: +
ISPEXEC DISPLAY PANEL(ECHANGE)

IF &LASTCC > 7 THEN +
    DO
        SET ZEDSMSG = &STR(NO CHANGE PERFORMED)
        ISPEXEC SETMSG MSG(UTLZ000)
        EXIT
    END

/**********************************************************************
/* INFORM THE USER OF THE ACTIVITY                                    *
/**********************************************************************
SET ZEDLMSG = &STR(CHANGING: &CFROM TO: &CTO +
                   PARMS: &CPARM)
ISPEXEC CONTROL DISPLAY LOCK
ISPEXEC DISPLAY MSG(UTLZ000W)

/**********************************************************************
/* LET'S FINALLY DO THE WORK!                                         *
/**********************************************************************
ISPEXEC VGET (CFROM CTO CPARM) SHARED
ISREDIT CHANGE &STR(&SYSNSUB(1,&CFROM)) +
               &STR(&SYSNSUB(1,&CTO)) +
               &STR(&SYSNSUB(1,&CPARM))

/**********************************************************************
/* TELL THE USER THE RESULTS AND GO BACK TO THE LINE THEY WERE ON     *
/**********************************************************************
SET CC = &LASTCC
ISREDIT (X,Y) = CHANGE_COUNTS
SET X = &X
SET Y = &Y
SELECT (&CC)
    WHEN (0) DO
        SET ZEDSMSG = &STR(CHANGE SUCCESSFUL)
        SET ZEDLMSG = &STR(CHANGED &X STRING OCCURANCES)
        ISPEXEC SETMSG MSG(UTLZ000)
    END
    WHEN (4) DO
        SET ZEDSMSG = &STR(STRING NOT FOUND)
        SET ZEDLMSG = &STR(COULD NOT FIND "&SYSNSUB(1,&CFROM)" +
        TO CHANGE)
        ISPEXEC SETMSG MSG(UTLZ001)
    END
    WHEN (8) DO
        SET ZEDSMSG = &STR(SOME DATA UNCHANGED)
        SET ZEDLMSG = &STR(&X OCCURANCES CHANGED AND &Y OCCURANCES +
                           UNCHANGED)
        ISPEXEC SETMSG MSG(UTLZ001)
    END
    OTHERWISE DO
        SET ZEDSMSG = &STR(SEVERE ECHANGE ERROR)
        SET ZEDLMSG = &STR(THE CHANGE HAD A RETURN CODE OF: &CC)
        ISPEXEC SETMSG MSG(UTLZ001)
    END
END
ISREDIT CURSOR = &LN &CL
EXIT

/**********************************************************************
/* DISPLAY ANY "HELP" WHICH IS AVAILABLE FOR THIS UTILITY             *
/**********************************************************************
HELPSEC: +
ISPEXEC SELECT PGM(ISPTUTOR) PARM(HELPSHEL)
SET ZEDLMSG = &STR(*** HELP DISPLAYED FOR ECHANGE UTILITY +
                   *** NO PROCESSING PERFORMED ***)
ISPEXEC SETMSG MSG(UTLZ000)
EXIT
            


Documentation


 ECHANGE is an edit macro which allows you to issue change commands which would
 not ordinarily fit on the edit command line or even on a PF key definition.
 Additionally, and perhaps even more important is that when ECHANGE is assigned
 to a PF key, and your cursor is in the body of your edit text, ECHANGE will
 automatically determine the space-delimited string that your cursor is on, and
 prepopulate the "change from" and "change to" strings on the ECHANGE data entry
 panel.

 When you invoke ECHANGE, you are presented with a screen which you can enter
 your change command in three basic components:

 1.  The "FROM" string (i.e. the string you are changing from).
 2.  The "TO" string (i.e. the string you are changing to).
 3.  Additional edit change command parameters (e.g. "X/NX", column numbers, a
     label range, etc.)

 These values are stored in your ISPF "shared" pool, so that the next time you
 invoke ECHANGE, those same values are there.  If you invoked ECHANGE as
 mentioned above, with your cursor "in" the data you are editing (as opposed to
 the COMMAND line), the "FROM" and "TO" string values will be the text string
 your cursor is placed on.  Any parameter values you had entered previously
 would still be there, however.

 To invoke ECHANGE, simply type echange on the command line of an edit session
 and press .  You can, of course, set this to a PF key as well (which can
 be very powerful).

 An additional feature to mix with cursor-specific operation of ECHANGE is the
 PREFIX (or SUFFIX) keyword.  The best way to explain this is with an example.

 Suppose that you were re-organizing the working storage of an existing ugly
 production program.  You had identified all the data names that were
 "accumulators", and you wanted to put them in the same area and prefix each one
 with an "A-" to better identify them in the code.  Instead of typing a change
 command for each one, you would do the following.

1. Set a PF key to ==> echange prefix a-
2. Place your cursor on one of the data names
3. Press the PF key

 ECHANGE now parses for the data name your cursor is on (for the sake of
 argument, let's say it's called MASTER-RECORDS-READ).  It would set the change
 "from" string to 'MASTER-RECORDS-READ' and the change "to" string to
 'A-MASTER-RECORDS-READ'.  In the "PARMS" field you would type "ALL" (this would
 remain until you changed it or until you got out of ISPF).

 When you press , you will be issuing the equivilent of the change
 command:

 c master-records-read a-master-records-read all

 With just ONE keystroke!  To process all these data names, you just position
 your cursor, press the PF key, and press .
            


Leave a Reply

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