Table of Contents |
See:
A.11 The optional File-Access word set
Table 11.1 - Data types
Symbol Data type Size on stack ------ --------- ------------- ior I/O results 1 cell fam file access method 1 cell fileid file identifiers 1 cell
An I/O exception in the execution of a File-Access word that can return an I/O result shall not cause a THROW; exception indications are returned in the ior.
Blocks may, but need not, reside in files. When they do:
See:
A.11.3.2 Blocks in files
See:
3.2.6 Environmental queries
Table 11.2 - Environmental query strings
String Value data type Constant? Meaning ------ --------------- --------- ------- FILE flag no file word set present FILE-EXT flag no file extensions word set present
Input with INCLUDED, INCLUDE-FILE, LOAD and EVALUATE shall be nestable in any order to at least eight levels.
A program that uses more than eight levels of input-file nesting has an environmental dependency.
See:
3.3.3.5 Input buffers,
9. Optional Exception word set.
See:
3.3.3.6 Other transient regions
Lines of at least 128 characters shall be supported. A program that requires lines of more than 128 characters has an environmental dependency.
A program may reposition the parse area within the input buffer by manipulating the contents of >IN. More extensive repositioning can be accomplished using SAVE-INPUT and RESTORE-INPUT.
See:
3.4.1 Parsing
The phrase Providing name(s) from the File Access Extensions word set shall be appended to the label of any Standard System that provides portions of the File Access Extensions word set.
The phrase Providing the File Access Extensions word set shall be appended to the label of any Standard System that provides all of the File Access and File Access Extensions word sets.
The phrase Requiring name(s) from the File Access Extensions word set shall be appended to the label of Standard Programs that require the system to provide portions of the File Access Extensions word set.
The phrase Requiring the File Access Extensions word set shall be appended to the label of Standard Programs that require the system to provide all of the File Access and File Access Extensions word sets.
11.6.1.0080 (
( "ccc<paren>" -- )
Extend the semantics of 6.1.0080 ( to include:
When parsing from a text file, if the end of the parse area is reached before a right parenthesis is found, refill the input buffer from the next line of the file, set >IN to zero, and resume parsing, repeating this process until either a right parenthesis is found or the end of the file is reached.
11.6.1.0765 BIN
( fam1 -- fam2 )
Modify the implementation-defined file access method fam1 to additionally select a binary, i.e., not line oriented, file access method, giving access method fam2.
See:
A.11.6.1.0765 BIN ,
11.6.1.2054 R/O ,
11.6.1.2056 R/W ,
11.6.1.2425 W/O
11.6.1.0900 CLOSE-FILE
( fileid -- ior )
Close the file identified by fileid. ior is the implementation-defined I/O result code.
11.6.1.1010 CREATE-FILE
( c-addr u fam -- fileid ior )
Create the file named in the character string specified by c-addr and u, and open it with file access method fam. The meaning of values of fam is implementation defined. If a file with the same name already exists, recreate it as an empty file.
If the file was successfully created and opened, ior is zero, fileid is its identifier, and the file has been positioned to the start of the file.
Otherwise, ior is the implementation-defined I/O result code and fileid is undefined.
See:
A.11.6.1.1010 CREATE-FILE
11.6.1.1190 DELETE-FILE
( c-addr u -- ior )
Delete the file named in the character string specified by c-addr u. ior is the implementation-defined I/O result code.
11.6.1.1520 FILE-POSITION
( fileid -- ud ior )
ud is the current file position for the file identified by fileid. ior is the implementation-defined I/O result code. ud is undefined if ior is non-zero.
11.6.1.1522 FILE-SIZE
( fileid -- ud ior )
ud is the size, in characters, of the file identified by fileid. ior is the implementation-defined I/O result code. This operation does not affect the value returned by FILE-POSITION. ud is undefined if ior is non-zero.
11.6.1.1717 INCLUDE-FILE
( i*x fileid -- j*x )
Remove fileid from the stack. Save the current input source specification, including the current value of SOURCE-ID. Store fileid in SOURCE-ID. Make the file specified by fileid the input source. Store zero in BLK. Other stack effects are due to the words included.
Repeat until end of file: read a line from the file, fill the input buffer from the contents of that line, set >IN to zero, and interpret.
Text interpretation begins at the file position where the next file read would occur.
When the end of the file is reached, close the file and restore the input source specification to its saved value.
An ambiguous condition exists if fileid is invalid, if there is an I/O exception reading fileid, or if an I/O exception occurs while closing fileid. When an ambiguous condition exists, the status (open or closed) of any files that were being interpreted is implementation-defined.
See:
11.3.4 Input source,
A.11.6.1.1717 INCLUDE-FILE
11.6.1.1718 INCLUDED
( i*x c-addr u -- j*x )
Remove c-addr u from the stack. Save the current input source specification, including the current value of SOURCE-ID. Open the file specified by c-addr u, store the resulting fileid in SOURCE-ID, and make it the input source. Store zero in BLK. Other stack effects are due to the words included.
Repeat until end of file: read a line from the file, fill the input buffer from the contents of that line, set >IN to zero, and interpret.
Text interpretation begins at the file position where the next file read would occur.
When the end of the file is reached, close the file and restore the input source specification to its saved value.
An ambiguous condition exists if the named file can not be opened, if an I/O exception occurs reading the file, or if an I/O exception occurs while closing the file. When an ambiguous condition exists, the status (open or closed) of any files that were being interpreted is implementation-defined.
See:
A.11.6.1.1718 INCLUDED ,
11.6.1.1717 INCLUDE-FILE
11.6.1.1970 OPEN-FILE
( c-addr u fam -- fileid ior )
Open the file named in the character string specified by c-addr u, with file access method indicated by fam. The meaning of values of fam is implementation defined.
If the file is successfully opened, ior is zero, fileid is its identifier, and the file has been positioned to the start of the file.
Otherwise, ior is the implementation-defined I/O result code and fileid is undefined.
11.6.1.2054 R/O
( -- fam )
fam is the implementation-defined value for selecting the read only file access method.
See:
11.6.1.1010 CREATE-FILE ,
11.6.1.1970 OPEN-FILE
11.6.1.2056 R/W
( -- fam )
fam is the implementation-defined value for selecting the read/write file access method.
See:
11.6.1.1010 CREATE-FILE ,
11.6.1.1970 OPEN-FILE
11.6.1.2080 READ-FILE
( c-addr u1 fileid -- u2 ior )
Read u1 consecutive characters to c-addr from the current position of the file identified by fileid.
If u1 characters are read without an exception, ior is zero and u2 is equal to u1.
If the end of the file is reached before u1 characters are read, ior is zero and u2 is the number of characters actually read.
If the operation is initiated when the value returned by FILE-POSITION is equal to the value returned by FILE-SIZE for the file identified by fileid, ior is zero and u2 is zero.
If an exception occurs, ior is the implementation-defined I/O result code, and u2 is the number of characters transferred to c-addr without an exception.
An ambiguous condition exists if the operation is initiated when the value returned by FILE-POSITION is greater than the value returned by FILE-SIZE for the file identified by fileid, or if the requested operation attempts to read portions of the file not written.
At the conclusion of the operation, FILE-POSITION returns the next file position after the last character read.
11.6.1.2090 READ-LINE
( c-addr u1 fileid -- u2 flag ior )
Read the next line from the file specified by fileid into memory at the address c-addr. At most u1 characters are read. Up to two implementation-defined line-terminating characters may be read into memory at the end of the line, but are not included in the count u2. The line buffer provided by c-addr should be at least u1+2 characters long.
If the operation succeeded, flag is true and ior is zero. If a line terminator was received before u1 characters were read, then u2 is the number of characters, not including the line terminator, actually read (0 <= u2 <= u1). When u1 = u2, the line terminator has yet to be reached.
If the operation is initiated when the value returned by FILE-POSITION is equal to the value returned by FILE-SIZE for the file identified by fileid, flag is false, ior is zero, and u2 is zero. If ior is non-zero, an exception occurred during the operation and ior is the implementation-defined I/O result code.
An ambiguous condition exists if the operation is initiated when the value returned by FILE-POSITION is greater than the value returned by FILE-SIZE for the file identified by fileid, or if the requested operation attempts to read portions of the file not written.
At the conclusion of the operation, FILE-POSITION returns the next file position after the last character read.
See:
A.11.6.1.2090 READ-LINE ,
RFI 0001.
11.6.1.2142 REPOSITION-FILE
( ud fileid -- ior )
Reposition the file identified by fileid to ud. ior is the implementation-defined I/O result code. An ambiguous condition exists if the file is positioned outside the file boundaries.
At the conclusion of the operation, FILE-POSITION returns the value ud.
11.6.1.2147 RESIZE-FILE
( ud fileid -- ior )
Set the size of the file identified by fileid to ud. ior is the implementation-defined I/O result code.
If the resultant file is larger than the file before the operation, the portion of the file added as a result of the operation might not have been written.
At the conclusion of the operation, FILE-SIZE returns the value ud and FILE-POSITION returns an unspecified value.
See:
11.6.1.2080 READ-FILE ,
11.6.1.2090 READ-LINE
11.6.1.2165 S"
Extend the semantics of 6.1.2165 S" to be:
Interpretation: ( "ccc<quote>" -- c-addr u )
Parse ccc delimited by " (double quote). Store the resulting string c-addr u at a temporary location. The maximum length of the temporary buffer is implementation-dependent but shall be no less than 80 characters. Subsequent uses of S" may overwrite the temporary buffer. At least one such buffer shall be provided.
Compilation: ( "ccc<quote>" -- )
Parse ccc delimited by " (double quote). Append the run-time semantics given below to the current definition.
Run-time: ( -- c-addr u )
Return c-addr and u that describe a string consisting of the characters ccc.
See:
3.4.1 Parsing,
6.2.0855 C" ,
A.11.6.1.2165 S" ,
11.3.5 Other transient regions.
11.6.1.2218 SOURCE-ID
( -- 0 | -1 | fileid )
Extend 6.2.2218 SOURCE-ID to include text-file input as follows:
SOURCE-ID Input source --------- ------------ fileid Text file fileid -1 String (via EVALUATE) 0 User input device
An ambiguous condition exists if SOURCE-ID is used when BLK contains a non-zero value.
11.6.1.2425 W/O
( -- fam )
fam is the implementation-defined value for selecting the write only file access method.
See:
11.6.1.1010 CREATE-FILE ,
11.6.1.1970 OPEN-FILE
11.6.1.2480 WRITE-FILE
( c-addr u fileid -- ior )
Write u characters from c-addr to the file identified by fileid starting at its current position. ior is the implementation-defined I/O result code.
At the conclusion of the operation, FILE-POSITION returns the next file position after the last character written to the file, and FILE-SIZE returns a value greater than or equal to the value returned by FILE-POSITION.
See:
11.6.1.2080 READ-FILE ,
11.6.1.2090 READ-LINE
11.6.1.2485 WRITE-LINE
( c-addr u fileid -- ior )
Write u characters from c-addr followed by the implementation-dependent line terminator to the file identified by fileid starting at its current position. ior is the implementation-defined I/O result code.
At the conclusion of the operation, FILE-POSITION returns the next file position after the last character written to the file, and FILE-SIZE returns a value greater than or equal to the value returned by FILE-POSITION.
See:
11.6.1.2080 READ-FILE ,
11.6.1.2090 READ-LINE
11.6.2.1524 FILE-STATUS
( c-addr u -- x ior )
Return the status of the file identified by the character string c-addr u. If the file exists, ior is zero; otherwise ior is the implementation-defined I/O result code. x contains implementation-defined information about the file.
11.6.2.1560 FLUSH-FILE
( fileid -- ior )
Attempt to force any buffered information written to the file referred to by fileid to be written to mass storage, and the size information for the file to be recorded in the storage directory if changed. If the operation is successful, ior is zero. Otherwise, it is an implementation-defined I/O result code.
11.6.2.2125 REFILL
( -- flag )
Extend the execution semantics of 6.2.2125 REFILL with the following:
When the input source is a text file, attempt to read the next line from the text-input file. If successful, make the result the current input buffer, set >IN to zero, and return true. Otherwise return false.
See:
7.6.2.2125 REFILL
11.6.2.2130 RENAME-FILE
( c-addr1 u1 c-addr2 u2 -- ior )
Rename the file named by the character string c-addr1 u1 to the name in the character string c-addr2 u2. ior is the implementation-defined I/O result code.