Introduction fo Byte-Oriented File Input/Output Routines
Byte-Oriented Input and Output File Open
Byte-Oriented Input and Output File Close
Byte-Oriented Input and Output
Error Return Codes
:Byte-Oriented File Input/Output Routines
Th� followin� documentatio� cover� th� serie� o� byte-�
oriente� fil� input/outpu� routine� i� SYSLIB�� Thes� routine� �
allo� th� use� t� sequentiall� rea� fro� (GET� an� writ� t� (PUT� �
� fil� o� � byte-for-byt� basis�� Hence�� thes� routine� provid� �
a� exceptionall� simpl� metho� fo� handlin� inpu� fro� an� outpu� �
t� � file.
� typica� progra� whic� employ� thes� routine� mus� ope� th� �
require� file� befor� doin� an� processing� mus� the� perfor� th� �
processin� o� th� opene� files�� an� mus� the� clos� th� file� �
whe� th� processin� i� complet� (closin� th� file� i� optiona� �
fo� inpu� file� an� mandator� fo� outpu� files).
SYSLI� provide� fou� set� o� routine� fo� byte-oriente� fil� �
inpu� an� output� Thes� routine� ar� --
Input Open Output Open GET PUT Input Close Output Close
---------- ----------- --- --� ----------- ------------
FI0$OPEN FO0$OPEN F0$GET F0$PUT FI0$CLOSE FO0$CLOSE
FI1$OPEN FO1$OPEN F1$GET F1$PUT FI1$CLOSE FO1$CLOSE
FI2$OPEN FO2$OPEN F2$GET F2$PUT FI2$CLOSE FO2$CLOSE
FI3$OPEN FO3$OPEN F3$GET F3$PUT FI3$CLOSE FO3$CLOSE
Thi� syste� allow� th� use� t� hav� u� t� �� file� ope� �
simultaneousl� -- fou� ar� ope� fo� inpu� usin� GE� an� fou� ar� �
ope� fo� outpu� usin� PUT�� Fo� example�� th� followin� i� � �
sampl� cod� sectio� usin� thes� routine� fo� tw� files:
EXT FI0$OPEN ; DECLARE LIBRARY REFERENCES
EXT FO0$OPEN
EXT FI0$CLOSE
EXT FO0$CLOSE
EXT F0$GET
EXT F0$PUT
...
LXI D,FCBI ; PT TO FCB OF INPUT FILE
CALL FI0$OPEN
LXI D,FCBO ; PT TO FCB OF OUTPUT FILE
CALL FO0$OPEN
...
[body containing CALL F0$GET and CALL F0$PUT where required]
...
CALL FI0$CLOSE ; CLOSE FILE
CALL FO0$CLOSE
...
END
Not� tha� onl� th� routine� t� b� use� ar� reference� i� th� �
EX� statements�� I� yo� d� no� nee� � particula� routine� d� no� �
referenc� it�� No� referencin� a� unneede� routin� generall� �
save� th� overhea� memor� spac� o� loadin� i� fro� th� library.
Eac� se� o� INPU� OPEN�� INPU� CLOSE�� OUTPUԠ OPEN�� OUTPU� �
CLOSE�� GET� an� PU� routine� i� containe� i� on� librar� module� �
s� referencin� an� o� thes� routine� cause� th� entir� modul� t� �
b� loaded�� an� al� th� routine� ar� accessabl� t� th� use� �
(provide� the� ar� mentione� i� th� externa� definitions� withou� �
an��� additiona� memor��� overhead��� Specifically��� FI0$OPEN� �
FI0$CLOSE�� FO0$OPEN� FO0$CLOSE� F0$GET� an� F0$PU� ar� containe� �
i� on� module�� an� referenc� t� an� o� thes� routine� load� th� �
entir� module� th� sam� i� tru� fo� th� othe� set� o� routines.
Th� CLOS� routin� fo� outpu� (FOn$CLOSE� i� ALWAY� required� �
i� fill� th� res� o� th� curren� bloc� wit� Ctrl-� followe� b� �
<NULL�� byte� an� properl� close� file�� Th� CLOSРroutin� fo� �
inpu� (FIn$CLOSE� i� require� ONL� I� yo� ar� goin� t� late� ope� �
anothe� fil� fo� inpu� usin� th� correspondin� OPEΠ routin� �
(FIn$OPEN)�� FIn$CLOSРonl� serve� t� rese� th� OPE� fla� (use� �
t� GE� t� ascertai� tha� th� fil� ha� bee� properl� opened).
:FI$OPEN and FO$OPEN, et al -- Byte-Oriented Input and Output File Open
Routine Names: FI0$OPEN, FI1$OPEN, FI2$OPEN, FI3$OPEN
Function�
Ope� th� fil� whos� FC� i� pointe� t� b� D� fo� inpu� �
(us� wit� F$GET)�� FIn$OPEРinitialize� th� FC fields�� s� �
further initialization is not necessary.
Inputs: DE = ptr to FCB of file to open
Outputs: Z Flag is Error Indicator, A is Error Code
Registers Affected: PSW
SYSLIB Routines Called: Internal
Special Error Conditions: See Section on Error Codes
Routine Names: FO0$OPEN, FO1$OPEN, FO2$OPEN, FO3$OPEN
Function�
Ope� th� fil� whos� FC� i� pointe� t� b� D� fo� outpu� �
(us� wit� F$PUT)�� FOn$OPE� initialize� th� FC fields�� s� �
furthe� initializatio� i� no� necessary�� I� als� create� th� �
indicated file if it does not already exist.
Inputs: DE = ptr to FCB of file to open
Outputs: Z Flag is Error Indicator, A is Error Code
Registers Affected: PSW
SYSLIB Routines Called: Internal
Special Error Conditions: See Section on Error Codes
:FI$CLOSE and FO$CLOSE, et al -- Byte-Oriented Input and Output File Close
Routine Names: FI0$CLOSE, FI1$CLOSE, FI2$CLOSE, FI3$CLOSE
Function�
Clos� th� fil� previousl� opene� b� th� correspondin� �
FI$OPEРroutine�� Us� o� thes� routine� i� optiona� i� th� �
anothe� fil� wil� no� b� opene� late� i� th� progra� b�� th� �
correspondin� FI$OPE� routine.
Inputs: -None-
Outputs: Z Flag is Error Indicator, A is Error Code
Registers Affected: PSW
SYSLIB Routines Called: Internal
Specia� Erro� Conditions: See Section on Error Codes
Routine Names: FO0$CLOSE, FO1$CLOSE, FO2$CLOSE, FO3$CLOSE
Function�
Clos� th� fil� previousl� opene� b� th� correspondin� �
FO$OPE� routine� Us� o� thes� routine� i� MANDATOR� afte� outpu� �
t� th� fil� (usin� th� correspondin� F$PU� routine� i� complete.
Inputs: -None-
Outputs: Z Flag is Error Indicator, A is Error Code
Registers Affected: -None-
SYSLIB Routines Called: Internal
Specia� Erro� Conditions: See Section on Error Codes
:F$GET and F$PUT, et al -- Byte-Oriented Input and Output
Routine Names: F0$GET, F1$GET, F2$GET, F3$GET
Function�
Ge� th� nex� byt� i� sequenc� fro� th� fil� previousl� �
opene� b� th� correspondin� FI$OPE� routine� Byt� i� returne� i� �
Registe� A.
Inputs: -None-
Outputs: A = Next byte from file if no error
If Error, NZ and A = Error Code
Registers Affected: PSW
SYSLIB Routines Called: Internal
Specia� Erro� Conditions: See Section on Error Codes
Routine Names: F0$PUT, F1$PUT, F2$PUT, F3$PUT
Function�
Pu� th� byt� i� Registe� � ont� th� en� o� th� fil� �
previousl� opene� b� th� correspondin� FO$OPE� routine.
Inputs: A = Byte to PUT
Outputs: Z Flag is Error Indicator, A is Error Code
Registers Affected: PSW
SYSLIB Routines Called: Internal
Specia� Erro� Conditions� See Section on Error Codes
:Error Return Codes
Fo� eac� o� th� routine� i� thi� se� o� byte-oriente� fil� �
I/� routines� th� Zer� Fla� an� th� � Registe� pla� � ke� rol� i� �
indicating the error conditions of the routines.
I� th� Zer� Fla� i� Se� (Z� afte� � routin� ha� bee� �
executed�� the� thi� indicate� tha� n� erro� ha� occurred� Th� � �
Registe� i� eithe� unaffecte� (i� mos� cases�� o� contain� � �
returned value (if so indicated, as in Fn$GET routines).
I� th� Zer� Fla� i� Clea� (NZ� afte� � routin� ha� bee� �
executed�� the� thi� indicate� tha� a� erro� ha� occurred� Th� � �
Registe� no�� contain� th� Erro� Code�� Th� followin� tabl� �
summarize� th� Erro� Code� whic� ma� b� returne� i� th� � �
Register.
The following screen display summarizes the Error Codes.
Summary of Error Codes
Returned by Byte-Oriented File I/O Routines
Code Meaning
---- -------
1 GET or PUT attempted on an unopened file
2 Disk Full (Ran out of space)
3 Input File Not Found
4 Attempt to Read Past EOF
5 Directory Full
6 Error in Closing a File
7 Attempt to Open a File which is already Open