/******************************************************************************/ /* */ /* Programmer : Hunter Goatley */ /* Program : SAVE.PLI */ /* Language : VAX-11 PL/1 v2.4 */ /* System : VAX 11/785 VAX/VMS v4.4 */ /* Purpose : Used to build a command procedure to re-define old */ /* temporary symbols and logicals */ /* Date : 26-JUN-1986 */ /* */ /******************************************************************************/ /* */ /* SAVE will build a command procedure to restore temporary global */ /* symbols and logicals. This program is called by SAVE.COM. (The */ /* command procedure SAVE.COM comprises the other part of this package.) */ /* SAVE.COM writes (by SHOW) all symbols and logicals currently defined */ /* out to files. SAVE.EXE finds differences in old symbol files and */ /* and new, redefining the old symbols not found in the new. */ /* */ /******************************************************************************/ /******************************************************************************/ /* */ /* PROCEDURE MAIN_SAVE */ /* */ /* FUNCTION - Opens output file and calls SAVE_SYM and SAVE_LOG to write */ /* to it. */ /* */ /* GLOBAL VARIABLES: */ /* */ /* INDEX Builtin PL/1 function */ /* */ /* LENGTH Builtin PL/1 function */ /* */ /* OUTFILE External File */ /* */ /* SUBSTR Builtin PL/1 function */ /* */ /******************************************************************************/ MAIN_SAVE : PROCEDURE OPTIONS(MAIN); DECLARE OUTFILE FILE OUTPUT; OPEN FILE(OUTFILE) OUTPUT TITLE('SYS$LOGIN:SAVED.COM'); CALL SAVE_SYM; CALL SAVE_LOG; CLOSE FILE(OUTFILE); /******************************************************************************/ /* */ /* SUBROUTINE SAVE_SYM */ /* */ /* FUNCTION - Writes to OUTFILE all global symbols defined in an earlier */ /* session that are not currently defined. After the DCL cmd */ /* SHOW SYMBOL has been written to files (for the old session */ /* and the current session), DCL DIFFERENCES is run. It is */ /* this "differences" file that is checked to determine those */ /* symbols undefined in the current session. */ /* */ /* LOCAL VARIABLES: */ /* */ /* CMD DCL command to redefine the symbol */ /* */ /* EOF End Of File flag for INFILE */ /* */ /* INFILE External File - DIFF_SYM.LIS */ /* */ /* INREC Buffer for INFILE input records */ /* */ /* X Temp variable used for INDEX */ /* */ /******************************************************************************/ SAVE_SYM : PROCEDURE; DECLARE INFILE FILE SEQUENTIAL INPUT, INREC CHARACTER(512) VARYING, CMD CHARACTER(512) VARYING, X FIXED BINARY(31), EOF BIT(1); ON ENDFILE(INFILE) EOF = '1'B; EOF = '0'B; OPEN FILE(INFILE) TITLE('SYS$LOGIN:DIFF_SYM.LIS'); PUT FILE(OUTFILE) EDIT ('$ ! Saved symbolic definitions') (A); CMD = ' '; READ FILE(INFILE) INTO(INREC); DO WHILE (^EOF); IF (LENGTH(INREC) = 6 & INREC = '******') THEN DO; READ FILE(INFILE) INTO(INREC); READ FILE(INFILE) INTO(INREC); DO WHILE(SUBSTR(INREC,1,1) ^= '*'); IF (CMD ^= ' ') THEN PUT FILE(OUTFILE) SKIP EDIT ('$ ',CMD) (A); INREC = SUBSTR(INREC,11); X = INDEX(INREC,'==') + 3; IF (SUBSTR(INREC,X,1) ^= '"') THEN INREC = SUBSTR(INREC,1,X+INDEX(SUBSTR(INREC,X,20),' ')); CMD = INREC; READ FILE(INFILE) INTO(INREC); END; END; CMD = ' '; READ FILE(INFILE) INTO(INREC); END; CLOSE FILE(INFILE); PUT FILE(OUTFILE) SKIP; END SAVE_SYM; /******************************************************************************/ /* */ /* SUBROUTINE SAVE_LOG */ /* */ /* FUNCTION - Writes to OUTFILE all process logicals defined in an earlier */ /* session that are not currently defined. After the DCL cmd */ /* SHOW LOGICAL has been written to files (for the old session */ /* and the current session), DCL DIFFERENCES is run. It is */ /* this "differences" file that is checked to determine those */ /* logicals undefined in the current session. */ /* */ /* LOCAL VARIABLES: */ /* */ /* CMD DCL command to redefine the symbol */ /* */ /* EOF End Of File flag for INFILE */ /* */ /* INFILE External File - DIFF_LOG.LIS */ /* */ /* INREC Buffer for INFILE input records */ /* */ /* LOGICAL The logical name */ /* */ /* X Temp variable used for INDEX */ /* */ /******************************************************************************/ SAVE_LOG : PROCEDURE; DECLARE INFILE FILE SEQUENTIAL INPUT, INREC CHARACTER(512) VARYING, CMD CHARACTER(512) VARYING, LOGICAL CHARACTER(100) VARYING, X FIXED BINARY(31), EOF BIT(1); ON ENDFILE(INFILE) EOF = '1'B; EOF = '0'B; OPEN FILE(INFILE) TITLE('SYS$LOGIN:DIFF_LOG.LIS'); PUT FILE(OUTFILE) EDIT ('$ ! Saved LOGICAL definitions') (A); CMD = ' '; READ FILE(INFILE) INTO(INREC); DO WHILE (^EOF); IF (LENGTH(INREC) = 6 & INREC = '******') THEN DO; READ FILE(INFILE) INTO(INREC); READ FILE(INFILE) INTO(INREC); DO WHILE(SUBSTR(INREC,1,1) ^= '*'); IF (CMD ^= ' ') THEN PUT FILE(OUTFILE) SKIP EDIT (CMD) (A); INREC = SUBSTR(INREC,12); X = INDEX(INREC,'"'); LOGICAL = SUBSTR(INREC,1,X-1); INREC = SUBSTR(INREC,INDEX(INREC,'=') + 2); IF (SUBSTR(LOGICAL,1,4) = 'SYS$' | LOGICAL = 'TT') THEN CMD = ' '; ELSE CMD = '$ DEFINE ' || LOGICAL || ' ' || INREC; READ FILE(INFILE) INTO(INREC); END; END; CMD = ' '; READ FILE(INFILE) INTO(INREC); END; CLOSE FILE(INFILE); END SAVE_LOG; END MAIN_SAVE;