Updating Files

This job is a simplified example of a job that updates files used on the system.

?BEGIN JOB UPDATE/FILES;
CLASS=7; %SPECIAL QUEUE FOR OPS JOBS.
JOBSUMMARY=UNCONDITIONAL;
STRING AX;
TASK CTASK;
SUBROUTINE REMOVEFILES;
BEGIN
REMOVE
 *SYMBOL/ABE , *SYMBOL/ALGOL , *SYMBOL/ALGOLSUPPLEMENT
 *SYMBOL/ALGOLTABLEGEN, *SYMBOL/ATTABLEGEN, *SYMBOL/BACKUP ,
 *SYMBOL/BNA , *SYMBOL/BNAV1/= , *SYMBOL/BNAENVIRONMENT,
 *SYMBOL/BOOTSTRAP, *SYMBOL/BUFFERMANAGER, *SYMBOL/CANDE ,
 *SYMBOL/CARDLINE, *SYMBOL/CCTABLEGEN
    FROM DISK;
END REMOVEFILES;
SUBROUTINE COPYFILES;
BEGIN
COPY
 *SYMBOL/ABE , *SYMBOL/ALGOL , *SYMBOL/ALGOLSUPPLEMENT
 *SYMBOL/ALGOLTABLEGEN, *SYMBOL/ATTABLEGEN, *SYMBOL/BACKUP,
 *SYMBOL/BNA , *SYMBOL/BNAV1/= , *SYMBOL/BNAENVIRONMENT,
 *SYMBOL/BOOTSTRAP, *SYMBOL/BUFFERMANAGER, *SYMBOL/CANDE ,
 *SYMBOL/CARDLINE, *SYMBOL/CCTABLEGEN
    FROM UPTAPE (TAPE) TO DISK (DISK) [CTASK];
IF CTASK (TASKVALUE) = 1 THEN
  BEGIN
    DISPLAY "COPYFILES DIDN'T WORK";
    AX:=ACCEPT ("ENTER YES TO RETRY COPYFILES OR NO TO GO ON");
    IF AX = "YES" THEN
      BEGIN
        INITIALIZE (CTASK);
        COPYFILES;
      END;
  END;
END COPYFILES;
ON RESTART, GO TRYAGAIN;
  TRYAGAIN:
  REMOVEFILES;
  COPYFILES;
  ?END JOB.

Explanation

The job attributes at the start specify the queue the job will be initiated from and ensure that a job summary will be printed.

The first subroutine, REMOVEFILES, removes a list of files from DISK. The second subroutine, COPYFILES, copies the new versions of those files from a tape named UPTAPE to DISK.

The REMOVEFILES subroutine is not strictly necessary if the system option 5 (AUTORM) is set, because in that case the COPY statement automatically removes any files on the destination volume that have the same titles as files that are being copied to that volume.

However, the COPY statement does not remove each old file until the file that is to replace it is completely copied over. This can cause a temporary shortage of disk space that could prevent the COPY from completing. Removing the old files prior to using the COPY statement ensures that this problem will not occur.

In the COPYFILES subroutine, the COPY is assigned the task variable CTASK. The TASKVALUE of the task is checked after the COPY completes to ensure that all files were copied successfully. If one or more of the files were not copied successfully (for example, because they were not present on the tape), then the TASKVALUE of the COPY task is 1.

If the COPY was not successful, messages are displayed asking the operator whether the COPY should be retried. The ACCEPT function assigns the operator's reply to a variable AX. If the reply was YES, the task variable CTASK is reinitialized and the subroutine invokes itself, thus causing the COPY to be tried over again.

The ON RESTART statement causes specified actions to be taken after a job is interrupted by a halt/load. In this case, both subroutines are rerun after a halt/load.