<Files>

[ open | close | fileerror | print | println | scan | scanln | eof ]


The values of the file type are file handles with only a limited number of operations.


Opening and closing files

exp ::= open ( exp )
exp ::= open ( exp , exp )
The first argument is a string designating a file on the server's file system. The second argument specifies the open mode and must be on of the strings "read", "write", or "append", defaulting to "read" if not present. The path is the $SERVICEDIR/<<service-name>>.

exp ::= close ( exp )
Will close the file associated with the file handle given as argument. The expression will return void.

exp ::= fileerror ( exp )
Takes an expression of type file and returns a boolean that is true if a previous open on the file was unsuccessful or an error has previously occurred reading from or writing to the file. Otherwise it return false.


Printing in files

exp ::= print ( exp , exp )
The string specified in the second argument is printed to the file designated by the first argument. The file must be in either write or append mode. The expression will return void.

exp ::= println ( exp , exp )
The string specified in the second argument plus a newline character is printed to the file designated by the first argument. The file must be in either write or append mode. The expression will return void.


Scanning in files

exp ::= scan ( exp , id )
Scan will take two arguments, a file handle and a format. It will scan as much of the file from the current file position that is in the regular language defined by the format and advance the file pointer accordingly. The file must be in read mode. The expression will return what was scanned from the file.

exp ::= scanln ( exp )
Scans and returns one line from the file specified in the argument. After this, the file pointer is advanced accordingly. The file must be in read mode.

exp ::= eof ( exp )
Returns a true if the file designated by the argument is at the end-of-file mark, false if not. The file must be in read mode.


bigwig@brics.dk
Last updated: November 2, 2001
Valid HTML 4.01!