~ chicken-core (chicken-5) /manual/Module (chicken io)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken io)56This module provides various Input/Output extensions.78=== read-list910<procedure>(read-list [PORT [READER [MAX]]])</procedure>1112Call {{READER}} up to {{MAX}} times and collect its output in a list. If {{MAX}} is {{#f}}, read until end of file.1314The reader is called with one argument: {{PORT}}.1516{{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.171819=== read-buffered2021<procedure>(read-buffered [PORT])</procedure>2223Reads any remaining data buffered after previous read operations on24{{PORT}}. If no remaining data is currently buffered, an empty string25is returned. This procedure will never block. Currently only useful26for string-, process- and tcp ports.2728=== read-byte29=== write-byte3031<procedure>(read-byte [PORT])</procedure><br>32<procedure>(write-byte BYTE [PORT])</procedure>3334Read/write a byte to the port given in {{PORT}}, which default to the values35of {{(current-input-port)}} and {{(current-output-port)}}, respectively.363738=== read-line39=== write-line4041<procedure>(read-line [PORT [LIMIT]])</procedure><br>42<procedure>(write-line STRING [PORT])</procedure>4344Line-input and -output. {{PORT}} defaults to the value of45{{(current-input-port)}} and {{(current-output-port)}},46respectively. If the optional argument {{LIMIT}} is given and47not {{#f}}, then {{read-line}} reads at most {{LIMIT}}48characters per line. {{read-line}} returns a string without the terminating newline and {{write-line}} adds a terminating newline before outputting.495051=== read-lines5253<procedure>(read-lines [PORT [MAX]])</procedure>5455Read {{MAX}} or fewer lines from {{PORT}}. {{MAX}} defaults to56{{most-positive-fixnum}} and {{PORT}} defaults to the value of57{{(current-input-port)}}. Returns a list of strings, each string58representing a line read, not including any line separation59character(s).606162=== read-string63=== read-string!64=== write-string6566<procedure>(read-string [NUM [PORT]])</procedure><br>67<procedure>(read-string! NUM STRING [PORT [START]])</procedure><br>68<procedure>(write-string STRING [NUM [PORT]])</procedure>6970Read or write {{NUM}} characters from/to {{PORT}}, which defaults to the71value of {{(current-input-port)}} or {{(current-output-port)}}, respectively.7273If {{NUM}} is {{#f}} or not given, then all data up to the end-of-file is74read, or, in the case of {{write-string}} the whole string is written. If no75more input is available, {{read-string}} returns {{#!eof}}.7677{{read-string!}} reads destructively into the given {{STRING}} argument, but78never more characters than would fit into {{STRING}}. If {{START}} is given,79then the read characters are stored starting at that position.80{{read-string!}} returns the actual number of characters read.818283=== read-token8485<procedure>(read-token PREDICATE [PORT])</procedure>8687Reads characters from {{PORT}} (which defaults to the value of {{(current-input-port)}})88and calls the procedure {{PREDICATE}} with each character until {{PREDICATE}} returns89false. Returns a string with the accumulated characters.9091---92Previous: [[Module (chicken gc)]]9394Next: [[Module (chicken irregex)]]