Trailing-Edge
-
PDP-10 Archives
-
decus_20tap1_198111
-
decus/20-0002/iomods.sai
There is 1 other file named iomods.sai in the archive. Click here to see a list.
ENTRY INITIN,INTTY,ENDIN,INITOUT,OUTTTY,ENDOUT;
BEGIN "IOMODS"
"
THE FOLLOWING ROUTINES ALLOW THE USER TO DO INPUT/OUTPUT WITH DISK
FILES, ALMOST AS EASILY AS WITH A TELETYPE. TO USE THESE ROUTINES
DO THE FOLLOWING:
1). INCLUDE THE FOLLOWING DECLARATIONS IN YOUR SOURCE PROGRAM.
EXTERNAL PROCEDURE INITIN(STRING FILIN;BOOLEAN NOCHK(FALSE));
EXTERNAL STRING PROCEDURE INTTY;
EXTERNAL PROCEDURE ENDIN;
EXTERNAL PROCEDURE INITOUT(STRING FILOUT;BOOLEAN VERIFY(TRUE));
EXTERNAL PROCEDURE OUTTTY(STRING S);
EXTERNAL PROCEDURE ENDOUT;
THE ABOVE MAY ALSO BE ACCOMPLISHED BY:
REQUIRE IOMODS.HDR[LEP,JRL] SOURCEFILE;
(WHERE IOMODS.HDR[LEP,JRL] IS CONTAINED WITHIN STRING QUOTES). THIS
SOURCEFILE ALSO DEFINES MACROS FOR CR,CRLF,TAB,VT,FF,LF.
2). REQUIRE THE LOADMODULE IOMODS.REL.(RESULT OF COMPILING THIS FILE)
EITHER IN YOUR SOURCE PROGRAM OR WHEN YOU LOAD THE PROGRAM.
3). TO OPEN THE DISK FILES CALL INITIN (IF AN INPUT FILE), INITOUT(IF AN
AN OUTPUT FILE). THE INITIALIZATION ROUTINE WILL THEN USE THE STRING
PARAMETER AS A FILE NAME. IF THE STRING IS TTY THE INPUT (OR OUTPUT)
WILL BE DONE WITH THE TELETYPE, ANY OTHER RESPONSE WILL BE TAKEN AS A DISK
FILE WHICH WILL BE LOOKUP'ED OR ENTER'ED.(THUS YOU ARE RESTRICTED
AND ARE NOT ALLOWED TO HAVE A DISK FILE NAMED TTY).
NOTE THAT IF YOU DO NOT CALL INITIN, OR INITOUT YOU WILL BE PROMPTED
FOR THE FILE NAME WHEN INTTY OR OUTTTY IS CALLED THE FIRST TIME.
4). WITHIN THE PROGRAM USE INTTY JUST AS YOU WOULD INCHWL AND OUTTTY
AS YOU WOULD OUTSTR.
5). BEFORE EXITING YOUR PROGRAM BE SURE TO EXECUTE AN ENDOUT TO CLOSE
YOUR OUTPUT FILES. AT ANY TIME DURING THE EXECUTION YOU MAY EXECUTE
AN ENDOUT OR ENDIN TO CLOSE YOUR FILES SO THAT YOU MAY OPEN OTHER
FILES FOR INPUT OR OUTPUT.
"
COMMENT INPUT;
DEFINE BRKTAB = 1;
DEFINE CRLF = "('15&'12)";
INTEGER CHANIN;
INTERNAL INTEGER INEOF;
OWN INTEGER EOFCHK;
INTERNAL PROCEDURE INITIN(STRING FNAME;BOOLEAN NOCHK(FALSE));
BEGIN
INTEGER COUNT,IOFLG,BRCHAR,GOODNAME;
IF NOCHK THEN EOFCHK_FALSE ELSE EOFCHK_TRUE;
IF CHANIN = 0 THEN
BEGIN
IOFLG _ TRUE;
GOODNAME _ LENGTH(FNAME);
WHILE IOFLG DO
BEGIN
WHILE GOODNAME DO
BEGIN OUTSTR("INPUT FILE NAME?");
FNAME _ INCHWL;
GOODNAME _ LENGTH(FNAME);
IF CHANIN THEN
BEGIN RELEASE(CHANIN);
CHANIN _ 0;
END;
END;
OPEN(CHANIN_GETCHAN,IF EQU(FNAME,"TTY")EQU(FNAME,"tty")
THEN "TTY" ELSE "DSK",0,2,0,COUNT,BRCHAR,INEOF);
COUNT _ 120;
LOOKUP(CHANIN,FNAME,IOFLG);
GOODNAME _ FALSE;
END;
SETBREAK(BRKTAB,'12,'15,"INS");
END ELSE USERERR(0,1,"TWO INITINS PREFORMED WITHOUT ENDIN");
END;
INTERNAL STRING PROCEDURE INTTY;
BEGIN STRING INSTRING;
IF CHANIN = 0 THEN
INITIN(NULL);
INSTRING _ INPUT(CHANIN,BRKTAB);
IF EOFCHKINEOF THEN USERERR(0,1,"READ PAST END OF INPUT FILE");
RETURN(INSTRING);
END;
INTERNAL PROCEDURE ENDIN;
BEGIN IF CHANIN THEN
BEGIN CLOSE(CHANIN);
RELEASE(CHANIN);
CHANIN_0;
END;
END;
COMMENT OUTPUT;
INTEGER CHANOUT;
INTERNAL PROCEDURE INITOUT(STRING FNAME;BOOLEAN VERIFY(TRUE));
BEGIN "INITOUT"
STRING DEV; INTEGER COUNT,BRCHAR,EOF,IOFLG;
INTEGER GOODNAME;
IF CHANOUT = 0 THEN
BEGIN
IOFLG _ TRUE;
GOODNAME _ LENGTH(FNAME);
WHILE IOFLG DO
BEGIN "WHILE IOFLG"
WHILE GOODNAME DO
BEGIN
OUTSTR("OUTPUT FILE NAME?");
FNAME _ INCHWL;
GOODNAME _ LENGTH(FNAME);
IF CHANOUT THEN
BEGIN
RELEASE(CHANOUT);
CHANOUT_0;
END;
END;
DEV_IF EQU(FNAME,"TTY")
THEN "TTY" ELSE "DSK";
OPEN(CHANOUT_GETCHAN,DEV,'10000,0,2,COUNT,BRCHAR,EOF);
IF VERIFY EQU("TTY",DEV) THEN
BEGIN
COMMENT HERE WE VERIFY THAT WE ARE NOT DESTROYING
SOME EXISTENT FILE;
LOOKUP(CHANOUT,FNAME,IOFLG);
IF IOFLG < 0 THEN
CASE IOFLG LAND '777777 OF
BEGIN
[0] ;
[1] BEGIN GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[2] BEGIN
OUTSTR(CRLF&"ATTEMPTED PROTECTION VIOLATION."&
" FILE "&FNAME&" ");
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[3] BEGIN
OUTSTR(CRLF&"FILE IN USE. FILE "&FNAME&" ");
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[4] BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[5] BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[6] BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[7] BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[10]
BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[11]BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END;
[12] BEGIN
GOODNAME _ FALSE;
CONTINUE "WHILE IOFLG";
END
END ELSE
BEGIN
INTEGER TINT;
GOODNAME _ FALSE;
IOFLG _ TRUE;
OUTSTR(CRLF&"OUTPUT FILE:"&FNAME&" ALREADY"&
" EXISTS. OVERWRITE?");
IF (TINT _ INCHWL)"Y" TINT"y" THEN
CONTINUE "WHILE IOFLG";
END;
CLOSIN(CHANOUT);
END;
ENTER(CHANOUT,FNAME,IOFLG);
IF IOFLG THEN
BEGIN
GOODNAME _ FALSE;
OUTSTR(CRLF&"UNABLE TO OPEN OUTPUT FILE "&FNAME&CRLF);
END;
END "WHILE IOFLG";
END ELSE USERERR(0,1,"TWO INITOUTS WITHOUT ENDOUT");
END;
INTERNAL PROCEDURE OUTTTY(STRING X);
BEGIN
IF CHANOUT = 0 THEN
INITOUT(NULL);
OUT(CHANOUT,X);
END;
INTERNAL PROCEDURE ENDOUT;
BEGIN IF CHANOUT THEN
BEGIN CLOSE(CHANOUT);
RELEASE(CHANOUT);
CHANOUT_0;
END;
END;
SIMPLE PROCEDURE INITIT;
BEGIN CHANIN_CHANOUT_0 END;
REQUIRE INITIT INITIALIZATION;
END "IOMODS"