Chicken » Module (chicken io)

## Module (chicken io)

This module provides various Input/Output extensions.

### read-list

read-list #!optional PORT READER MAXprocedure

  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

read-buffered #!optional PORTprocedure

  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

read-byte #!optional PORTprocedure
write-byte BYTE #!optional PORTprocedure

  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

read-line #!optional PORT LIMITprocedure
write-line STRING #!optional PORTprocedure

  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

read-lines #!optional PORT MAXprocedure

  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!

### write-string

read-string #!optional NUM PORTprocedure
read-string! NUM STRING #!optional PORT STARTprocedure
write-string STRING #!optional NUM PORTprocedure

  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-token

read-token PREDICATE #!optional PORTprocedure

  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)