Mainframe Utility: BRANCHBK

Return to Mainframe Utilities Page

Module


ISREDIT MACRO (HELP)
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 &HELP = &STR(HELP) THEN GOTO HELPSEC
/**********************************************************************
/* UTILITY: BRANCHBK                                                  *
/* AUTHOR: DAVE LEIGH                                                 *
/* FUNCTION: USED IN CONJUNCTION TO BRANCH "BACK" TO WHERE YOU WERE   *
/*           BEFORE ISSUING THE "BRANCH" COMMAND.                     *
/**********************************************************************

/**********************************************************************
/* WHAT EDIT PROFILE NUMBERING SCHEME IS BEING USED?                  *
/**********************************************************************
ISREDIT (X,Y) = NUMBER
IF &X = ON AND &SYSINDEX(&STR( COBOL),&STR(&Y)) > 0 THEN +
    DO
        SET COL1 = 1
        SET COL2 = 66
    END
ELSE +
    DO
        SET COL1 = 7
        SET COL2 = 72
    END

/**********************************************************************
/* WHAT BRANCH LEVEL ARE WE CURRENTLY AT?                             *
/**********************************************************************
ISPEXEC VGET BCHLVL SHARED
IF &BCHLVL < 1 THEN +
    DO
        SET ZEDSMSG = &STR(NO BRANCH BACK POINT)
        ISPEXEC SETMSG MSG(UTLZ001)
        EXIT
    END

ISPEXEC VGET (BCHT&BCHLVL BCHV&BCHLVL +
              BCHB&BCHLVL BCHI&BCHLVL) SHARED

SET DISPLINE = &&BCHT&BCHLVL
SET VERBLINE = &&BCHV&BCHLVL
SET OCCURANCE = &&BCHI&BCHLVL
SET SYSDVAL = &&BCHB&BCHLVL
SET SYSDVAL = &SYSDVAL
READDVAL LEFT RIGHT LRECL
IF &COL2  < &RIGHT THEN SET VERBLINE = &SUBSTR(1:&COL2,&STR(&VERBLINE))
ELSE +
IF &RIGHT < &LRECL THEN SET VERBLINE = &SUBSTR(1:&RIGHT,&STR(&VERBLINE))

/**********************************************************************
/* SEE IF WE CAN FIND THE PLACE TO BRANCH BACK TO.                    *
/**********************************************************************
SET QT = &STR(')
IF &SYSINDEX(&STR('),&STR(&VERBLINE)) > 0 THEN +
    IF &SYSINDEX(&STR("),&STR(&VERBLINE)) > 0 THEN
    ELSE SET QT = &STR(")

SET X = 1
ISREDIT FIND FIRST &STR(&QT&VERBLINE&QT)

DO WHILE &X ¬= &OCCURANCE AND &LASTCC = 0
    SET X = &X + 1
    ISREDIT FIND NEXT &STR(&QT&VERBLINE&QT)
END

ISREDIT LABEL .ZCSR = .CURR

ISREDIT UP &DISPLINE

/**********************************************************************
/* FIND THE NEXT "GO TO" OR "PERFORM" ON THIS SCREEN IF POSSIBLE.     *
/**********************************************************************
ISREDIT (LINE,CL) = CURSOR
ISREDIT (X,Y) = DISPLAY_LINES
ISREDIT LABEL &X = .X
ISREDIT LABEL &Y = .Y
ISREDIT FIND LAST P'=' &COL1 &COL2 .CURR .CURR
ISREDIT FIND NEXT ' GO ' &COL1 &COL2 .X .Y
ISREDIT (GOTO,NULL) = CURSOR
ISREDIT FIND LAST P'=' &COL1 &COL2 .CURR .CURR
ISREDIT FIND NEXT ' PERFORM ' &COL1 &COL2 .X .Y
ISREDIT (PERFORM,NULL) = CURSOR
ISREDIT FIND LAST P'=' &COL1 &COL2 .CURR .CURR
ISREDIT FIND NEXT ' EXIT. ' &COL1 &COL2 .X .Y
IF &LASTCC > 0 THEN SET EXIT = &Y
ELSE ISREDIT (EXIT,NULL) = CURSOR
SET X = &LINE
IF &PERFORM > &LINE AND +
   &PERFORM <= &EXIT THEN +
    SET X = &PERFORM
IF (&GOTO > &LINE AND +
    &GOTO <= &EXIT) AND +
   ((&PERFORM > &LINE AND +
     &GOTO < &PERFORM) OR +
    (&PERFORM = &LINE)) THEN +
    SET X = &GOTO
ISREDIT LOCATE .X
ISREDIT CURSOR = &X 1

SET BCHLVL = &BCHLVL - 1
ISPEXEC VPUT BCHLVL SHARED

EXIT
            


Documentation


 This edit macro works in conjunction with edit macro BRANCH. The BRANCH macro
 will allow you to branch to a subroutine by placing your cursor on a line with
 a PERFORM statement and typeing BRANCH on the command line (you) would probably
 put the command on an unused PF key.  Then by using BRANCHBK (probably assigned
 to another PF key), you could branch back to where you were in the edit
 session.  This combination of edit macros can be useful for finding your way
 through code in a COBOL program without losing your place.  It is especially
 helpful if you don't have a hard copy version to reference.
            


Leave a Reply

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