Node:Ports, Next:Input, Previous:Input and output, Up:Input and output
Ports represent input and output devices. To Scheme, an input port is a Scheme object that can deliver characters upon command, while an output port is a Scheme object that can accept characters.
call-with-input-file string proc | library procedure |
call-with-output-file string proc | library procedure |
String should be a string naming a file, and
proc should be a procedure that accepts one argument.
For Rationale: Because Scheme's escape procedures have unlimited extent, it is possible to escape from the current continuation but later to escape back in. If implementations were permitted to close the port on any escape from the current continuation, then it would be impossible to write portable code using both |
input-port? obj | procedure |
output-port? obj | procedure |
Returns #t if obj is an input port or output port respectively, otherwise returns #f. |
current-input-port | procedure |
current-output-port | procedure |
Returns the current default input or output port. |
with-input-from-file string thunk | optional procedure |
with-output-to-file string thunk | optional procedure |
String should be a string naming a file, and
proc should be a procedure of no arguments.
For |
open-input-file filename | procedure |
Takes a string naming an existing file and returns an input port capable of delivering characters from the file. If the file cannot be opened, an error is signalled. |
open-output-file filename | procedure |
Takes a string naming an output file to be created and returns an output port capable of writing characters to a new file by that name. If the file cannot be opened, an error is signalled. If a file with the given name already exists, the effect is unspecified. |
close-input-port port | procedure |
close-output-port port | procedure |
Closes the file associated with port, rendering the port incapable of delivering or accepting characters. These routines have no effect if the file has already been closed. The value returned is unspecified. |