Module (chicken io)
This module provides various Input/Output extensions.
read-list
[procedure] (read-list [PORT [READER [MAX]]])Call READER up to MAX times and collect its output in a list. If MAX is #f, read until end of file.
The reader is called with one argument: PORT.
READER defaults to read, MAX to #f and PORT to current-input-port, so if you call it with no arguments, it will read all remaining s-expressions from the current input port.
read-buffered
[procedure] (read-buffered [PORT])Reads any remaining data buffered after previous read operations on PORT. If no remaining data is currently buffered, an empty string is returned. This procedure will never block. Currently only useful for string-, process- and tcp ports.
read-byte
write-byte
[procedure] (read-byte [PORT])[procedure] (write-byte BYTE [PORT])
Read/write a byte to the port given in PORT, which default to the values of (current-input-port) and (current-output-port), respectively.
read-line
write-line
[procedure] (read-line [PORT [LIMIT]])[procedure] (write-line STRING [PORT])
Line-input and -output. PORT defaults to the value of (current-input-port) and (current-output-port), respectively. If the optional argument LIMIT is given and not #f, then read-line reads at most LIMIT characters per line. read-line returns a string without the terminating newline and write-line adds a terminating newline before outputting.
read-lines
[procedure] (read-lines [PORT [MAX]])Read MAX or fewer lines from PORT. MAX defaults to most-positive-fixnum and PORT defaults to the value of (current-input-port). Returns a list of strings, each string representing a line read, not including any line separation character(s).
read-string
read-string!
[procedure] (read-string [NUM [PORT]])[procedure] (read-string! NUM STRING [PORT [START]])
Read or write NUM characters from/to PORT, which defaults to the value of (current-input-port) or (current-output-port), respectively.
If NUM is #f or not given, then all data up to the end-of-file is read, or, in the case of write-string the whole string is written. If no more input is available, read-string returns #!eof.
read-string! reads destructively into the given STRING argument, but never more characters than would fit into STRING. If START is given, then the read characters are stored starting at that position. read-string! returns the actual number of characters read.
read-bytevector
[procedure] (read-bytevector [NUM [PORT]])Read NUM bytes from PORT, which defaults to the value of (current-input-port). read-bytevector allocates a new buffer and returns it (or the end-of-file object, if at the end of the input file).
If NUM is optional and not given, then all remaining input is read or the whole bytevector is read/written.
read-bytevector!
[procedure] (read-bytevector! BYTEVECTOR [PORT START END])Read bytes from PORT into BYTEVECTOR. PORT defaults to the value of (current-input-port) and returns the actual number of bytes read.
START and END designate the range of bytes that should be filled with input from PORT. If END exceeeds the length of BYTEVECTOR only as much data is read as fits into the destination buffer.
write-bytevector
[procedure] (write-bytevector BYTEVECTOR [PORT START END])Write bytes from BYTEVECTOR to PORT. PORT defaults to the value of (current-output-port).
START and END designate the range of bytes that should be written. If END exceeeds the length of BYTEVECTOR only as much data is written as is available.
read-token
[procedure] (read-token PREDICATE [PORT])Reads characters from PORT (which defaults to the value of (current-input-port)) and calls the procedure PREDICATE with each character until PREDICATE returns false. Returns a string with the accumulated characters.
Previous: Module (chicken gc)
Next: Module (chicken irregex)