.; ENDPAG.IND - Control file to manipulate the printer .; when two or more accounts are using Saturn. .; .; Invoked from a command file by: .; IND SY:ENDPAG SET when Saturn is being started. .; or .; IND SY:ENDPAG TST when Saturn is finishing. .; .; Written by: .; R. W. Barnard .; BIO/Comp Applications .; P. O. Box 18007 .; Albuquerque, NM 87185 .; .; Version 1.1, 14-Jan-88. .; .disable octal, lowercase .; .sets PRINTR "LP:" .;Change this for your printer. .; .sets SATEPF "SY:ENDPAG.DAT" .setn WAITIM 128 .setn FAC 4 .sets FLAG P1 .; .if FLAG eq "TST" .setn FAC 2 .; .; SET Reads the semaphore file and increment the semaphore. .; If it is then 1, ENDPAG is set to 0, as it should be for Saturn. .; .; TEST Reads the semaphore file and decrements the semaphore. .; If it is then 0, it resets ENDPAG to 1, as it should be for normal .; operations. .; .loop: .onerr wait .openr 'SATEPF' .read SEMAPH .purge .; By purging the semaphore file after reading it, a race condition .; is reduced, because another account won't find the file. .; .setn EPSEM 'SEMAPH' .if FLAG eq "TST" .goto eptest .; .inc EPSEM .if EPSEM eq 1 SET 'PRINTR' ENDPAG=0 .goto write .; .eptest:.dec EPSEM .if EPSEM eq 0 SET 'PRINTR' ENDPAG=1 .; .write: .open 'SATEPF' .data 'EPSEM' .close .; Now write the file for all to see. .exit .; .wait: .setn WAITIM WAITIM/FAC .; Don't let things loop forever. .if WAITIM le 1 .goto abort .delay 'WAITIM'T .goto loop .; .abort: ;ENDPAG.IND-F- ;The file 'SATEPF' does not exist, or other race condition. .exit