Next: , Previous: , Up: The File Library   [Index]


11.7.5 File Input Functions

Unless otherwise noted, functions return -1 if nothing was read (end of file was met).

f_case

integer f_case(file f, text &s);

reads the f file until the next zero character or until the files expires and sets s to the read result. The next read will start with the character just after the met zero.

returns the length of s, -1 if nothing was read (end of file was met)

f_ever

integer f_ever(file f, text c, text &s);

reads the f file for as long as the read characters do not belong to the c character set and sets s to the read result. The next read will start with the met in c character.

returns the length of s, -1 if nothing was read (end of file was met)

f_fast

integer f_fast(file f, text c, text &s);

reads the f file interpreting the C escape sequences for as long as the read unescaped characters do not belong to the c character set and sets s to the read result. The escaped characters are copied into the result. The next read will start with the met in c character.

returns the length of s, -1 if nothing was read (end of file was met)

f_head

integer f_head(file f, text &s);

reads the f file interpreting the C escape sequences until the next new line character (the next unescaped new line character, that is) or until the files expires and sets s to the read result. The next read will start with the character just after the met (unescaped) new line.

returns the length of s, -1 if nothing was read (end of file was met)

The backslash/new-line sequence is not interpreted as line continuation, it is interpreted as a new-line.

f_lead

integer f_lead(file f, text &s);

reads the f file interpreting the C escape sequences until the next new line character (the next unescaped new line character, that is) or until the files expires and sets s to the read result. The next read will start with the character just after the met (unescaped) new line.

returns the length of s, -1 if nothing was read (end of file was met)

The backslash/new-line sequence is interpreted as line continuation (and thus ignored), and not as a new-line.

f_line

integer f_line(file f, text &s);

reads the f file until the next new line character or until the files expires and sets s to the read result. The next read will start with the character just after the met new line.

returns the length of s, -1 if nothing was read (end of file was met)

f_list

integer f_list(file f, list l, integer n);

reads the f file interpreting the C escape sequences until the next new line character (the next unescaped new line character, that is) or until the files expires and splits the read result into words in the l list. The next read will start with the character just after the met (unescaped) new line.

returns the sum of the stored word lengths, -1 if nothing was read (end of file was met)

The backslash/new-line sequence is interpreted as line continuation (and thus ignored), and not as a new-line.

White space (space and tab character sequences) separates words.

The l list is cleared before storing any strings with it. The read words are appended (as strings, data of the intrinsic ‘text’ type) to the list, in the order in which they are read.

If n is not zero, all but the first n - 1 read words are stored in the l list as a single string - the concatenation of these all but the first n - 1 with a single space character inserted in between two consecutive words.

f_mind

integer f_mind(file f, text c, text &s);

reads the f file interpreting the C escape sequences for as long as the read unescaped characters belong to the c character set and sets s to the read result. The escaped characters are copied into the result. The next read will start with the met not in c character.

returns the length of s, -1 if nothing was read (end of file was met)

f_near

integer f_near(file f, text c, text &s);

reads the f file for as long as the read characters belong to the c character set and sets s to the read result. The next read will start with the met not in c character.

returns the length of s, -1 if nothing was read (end of file was met)

f_news

integer f_news(file f, list l, integer n, integer bits, text separators);

reads the f file like f_list does. separators specifies the list of words separating characters. bits is a bitwise OR of flags further specifying the task.

See File News Definitions.

f_list(f, l, n)’ and ‘f_news(f, l, n, 0, " \t")’ are equivalent.

returns the sum of the stored word lengths, -1 if nothing was read (end of file was met)

f_peek

integer f_peek(file f);

reads a character from the f file without removing it from the read buffer. The next read, if any, will start with the read character (just as if ‘f_peek’ was never called).

returns the read character as a positive value, -1 if none was read

f_peep

integer f_peep(file f, integer i);

reads the ith subsequent character from the f file without removing it from the read buffer. Calling ‘f_peep’ has no effect on subsequent reads. i needs to be positive and less than the read buffer size. ‘f_peek(f)’ and ‘f_peep(f, 0)’ are equivalent.

See Miscellaneous File Definitions.

returns the read character as a positive value, -1 if none was read

f_pick

integer f_pick(file f);

reads a character from the f file. The next read will start with the character just after the read one.

returns the read character as a positive value, -1 if none was read

f_word

integer f_word(file f, text &s);

skips any character until the first neither space nor tab, reads the f file until the first space, tab or next new line character or until the files expires and sets s to the read result. The next read will start with the met space, tab or new line character, except for when new line was met before reading any non space, tab or new line character, case in which the next read will start with the character after the met new line character.

returns the length of s, -2 if new line was met before reading any non space, tab or new line character, -1 if nothing was read (end of file was met)

s will be the empty string for negative returns.

f_yank

integer f_yank(file f);

reads a character from the f file. The next read will start with the character just after the read one. Unlike ‘f_pick(f)’ it does not admit short reads.

returns the read character as a positive value


Next: , Previous: , Up: The File Library   [Index]