Contents | < Browse | Browse >
9A. io functions
prints a string (which may contain formatting codes) to stdout. Zero
to unlimited arguments may be added. Note that, as formatstrings may
be created dynamically, no check on the correct number of arguments
is (can be) made. Examples:
WriteF('Hello, World!\n') /* just write a lf terminated string */
WriteF('a = \d \n',a) /* writes: "a = 123", if a was 123 */
(see 2F about strings for more).
NOTE: if stdout=NIL, for example if your program was started from the
Workbench, WriteF() will create an output window, and put the handle
in conout and stdout. This window will automatically be closed on
exit of the program, after the user typed a <return>. WriteF() is the
only function that will open this window, so if you want to do IO
on stdout, and want to be sure stdout<>NIL, perform a "WriteF('')"
as first instruction of your program to ensure output. If you want
to open a console window yourself, you may do so by placing the resulting
file handle in the 'stdout' and 'conout' variables, as your window will
then be closed automatically upon exit. If you wish to close this window
manually, make sure to set 'conout' back to NIL, to signal E that there's
no console window to be closed. PrintF() is the same as WriteF only
uses the v37+ buffered IO.
both return the length of the string that was printed.
Out(filehandle,char) and char:=Inp(filehandle)
Either write or read one single byte to some file or stdout
if char=-1 then an EOF was reached, or an error occurred.
Out returns the number of bytes actually written (<>1 is error).
The functions use dos.library unbuffered IO, and as such are
slow for large amounts of data.
lets you determine the length of a file you *may* wish to load, and
also, if it exists (returns -1 upon error/file not found).
(see 9B )
Sets the standard output variable 'stdout' (not the value
returned from Input() and Output()!). Equivalent for:
oldout:=stdout; stdout:=newstdout. Same goes for the stdin