MAINSAIL Language Manual, Section 32.66

previous   next   top   contents   index   framed top   this page unframed


32.66. cRead

Figure 32–66. cRead (GENERIC)
$BUILTIN
INTEGER
PROCEDURE   cRead       (MODIFIES STRING s);

INTEGER
PROCEDURE   cRead       (POINTER(textFilef);

$BUILTIN
INTEGER
PROCEDURE   cRead       (MODIFIES CHARADR c);

INTEGER
PROCEDURE   cRead       (POINTER(dataFilef);

cRead returns the character code of either the current character in an input file, or the first character of a STRING, or the character addressed by a CHARADR. After the character is obtained, the file is positioned to the next character, or the character is removed from the STRING, or the CHARADR is displaced by one character.

In the case of a data file, characters are stored one per character unit, as in a text file. If a null or carriage return character is present at the current position in a data file, it is returned by cRead; in other words, data files always act as if the keepNul bit were set, regardless of the setting of that bit when the file was opened.

In the file forms, if the file is opened for PDF I/O, the character may be translated from the PDF to the host character set.

-1 is returned by the STRING and file forms if the STRING is "" or the end of the file has been reached. cRead from NULLCHARADR is undefined.

Example:

i := cRead(f)

reads the current character from the text file f and puts its code into i. f is then positioned to the next character.


previous   next   top   contents   index   framed top   this page unframed

MAINSAIL Language Manual, Section 32.66