Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Conklin E.K.Forth programmer's handbook.2000.pdf
Скачиваний:
321
Добавлен:
23.08.2013
Размер:
2.04 Mб
Скачать

Forth Programmer’s Handbook

fileid, read up to u1 consecutive characters, storing them at c-addr. Terminate the read if end-of-line delimiter(s) are encountered. Return an ior and u2, the number of characters successfully read, not including the line delimiter(s) if any. One or two line delimiters may be read into memory at the end of the line in addition to u2; therefore, the buffer at c-addr should be at least u1+2 characters long. If u2 = u1, the line delimiter was not reached. If no exception occurs, return ior of zero and flag is true. If FILE-POSITION was equal to FILESIZE before executing READ-LINE, flag is false, ior is zero, and u2 is zero. If an non-zero ior is returned, other returned parameters are undefined.

REFILL

( — flag )

Block Ext, Core Ext, File Ext

When the input source is a text file, attempt to read the next line from the cur-

rent file. If successful, make the result the current input buffer, set >IN to zero,

and return true; otherwise, return false.

 

WRITE-FILE

( c-addr u fileid — ior )

File

Write u characters from c-addr to the file identified by fileid, starting at its current file position. Increase FILE-SIZE if necessary. Return an I/O result code. After this operation, FILE-POSITION returns the next file position after the last character written to the file, and FILE-SIZE returns a value equal to or greater than FILE-POSITION.

WRITE-LINE ( c-addr u fileid — ior ) File

Same as WRITE-FILE, except a line terminator is written to the file after the u characters.

3.5.4

File Support Words

 

 

 

The words in this section provide support for other file access functions.

 

 

 

 

 

 

Glossary

 

 

BIN

( fam1 — fam2 )

File

Modify the given file access method fam1 to additionally select a binary (not line-oriented) file access method, returning the modified access method fam2.

100 System Functions

Core, File

 

 

Forth Programmer’s Handbook

FILE-POSITION

( fileid — ud ior )

File

Return the double-cell current file position ud for the file identified by fileid, and an I/O result code. If the ior is non-zero, the position ud is undefined.

FILE-SIZE ( fileid — ud ior ) File

Return the double-length file size ud for the file identified by fileid, and an I/O result code. This operation does not affect the value returned by FILE-POSI- TION. If the ior is non-zero, the size ud is undefined.

FILE-STATUS ( c-addr u — x ior ) File Ext

Return the status of the file whose name is given by the character string at c-addr and whose length is u. The ior is zero if the file exists, otherwise it is a systemdependent value. Cell x contains system-dependent information about the file.

R/O

( — fam )

File

Return the read-only file access method. “R-O”

 

R/W

( — fam )

File

Return the read/write file access method. “R-W”

 

REPOSITION-FILE

( ud fileid — ior )

File

For the file identified by fileid, reset the file position to ud, and return an I/O result code. After this operation (if successful), FILE-POSITION will return this same value for ud.

S" <string>" ( — c-addr u )

This word normally compiles a string in a definition, returning its address and count when executed. In a file-based disk access system, this word is extended to operate interpretively, for use with filenames. When interpreting, looks ahead in the input stream and obtains a character string, delimited by ". Stores the string in a temporary buffer (which is at least 80 characters long) and returns the address and length of the string. “S-quote”

W/O

( — fam )

File

 

Return the write-only file access method. “W-O”

 

System Functions 101

Соседние файлы в предмете Электротехника