Generated: Monday, November 14, 2011, 09:16:30 Copyright © 2011 , Kurt Nørmark The local LAML software home page

Reference Manual of the Text File Reading and Writing Library

Kurt Nørmark © normark@cs.aau.dk Department of Computer Science, Aalborg University, Denmark.

LAML Source file: lib/file-read.scm

This library provides a number of functions that reads a string from a text file, and functions which write a string to a text file. In particular the library supports very useful functions that read selected parts of a text file to strings.

The main functions are: read-text-file and write-text-file. The selective reading functions are read-text-file-between-marks and read-text-file-including-marks.

Table of Contents:
1. Reading stuff. 2. Writing stuff.

Alphabetic index:
code-example (code-example file . mark) Convenient and specialized function returning the contents of a program file.
read-text-file (read-text-file file-name) Return the textual contents of file-name, as a string
read-text-file-between-marks (read-text-file-between-marks file-name mark) Reads the part of the file between - but excluding - two occurences of mark, and return it as a text string.
read-text-file-from-input-port (read-text-file-from-input-port input-port) Return the textual contents of input-port, as a string
read-text-file-including-marks (read-text-file-including-marks file-name start-mark end-mark) Reads the part of the file between and including occurences of start-mark and end-mark, and return it as a text string.
write-port-strings (write-port-strings port . strings) Write each of the strings in the parameter strings to port.
write-string-to-port (write-string-to-port str port [suppress-cr]) Write the string str to port, which is assumed to be open.
write-text-file (write-text-file str file-name [suppress-cr]) Write the text string str to the file named file-name.


1 Reading stuff.

read-text-file
Form (read-text-file file-name)
Description Return the textual contents of file-name, as a string
See also Scheme source file read-text-file

read-text-file-from-input-port
Form (read-text-file-from-input-port input-port)
Description Return the textual contents of input-port, as a string
See also Scheme source file read-text-file-from-input-port

read-text-file-between-marks
Form (read-text-file-between-marks file-name mark)
Description Reads the part of the file between - but excluding - two occurences of mark, and return it as a text string. Specifically, it read and return the string from, but excluding, the first occurence of mark to, but excluding, the next occurence of mark. If no occurence of mark can be located, return the empty string. If only one occurence of mark occurs, return a suffix of the file from the mark to the end of file. This function is implemented by means of a state machine which controls when the actual reading must take place.
See also Scheme source file read-text-file-between-marks

read-text-file-including-marks
Form (read-text-file-including-marks file-name start-mark end-mark)
Description Reads the part of the file between and including occurences of start-mark and end-mark, and return it as a text string. Specifically, read and return the string from and including the first occurence of start-mark to and including the next occurence of end-mark. If no occurence of the mark can be located, return the empty string. If only the start-mark occurs, return a suffix of the file from the start-mark to the end of file. This function is implemented by means of a state machine which controls when the actual reading must take place.
See also Scheme source file read-text-file-including-marks

code-example
Form (code-example file . mark)
Description Convenient and specialized function returning the contents of a program file. Other usages are also possible. Reads an external file, either an entire file (if no optional mark parameter) or a region surrounded by mark.
See also Scheme source file code-example


2 Writing stuff.

write-text-file
Form (write-text-file str file-name [suppress-cr])
Description Write the text string str to the file named file-name. After this function call, the file contains exactly the string str. Opening and closing is done by this function.
Parameters suppress-cr If true, never write a cr (character 13). Ie. never use PC end of line conventions.
See also Scheme source file write-text-file

write-string-to-port
Form (write-string-to-port str port [suppress-cr])
Description Write the string str to port, which is assumed to be open. This procedure does not close the port.
Parameters suppress-cr If true, never write a cr (character 13). Ie. never use PC end of line conventions.
See also Scheme source file write-string-to-port
similar function write-port-strings

write-port-strings
Form (write-port-strings port . strings)
Description Write each of the strings in the parameter strings to port. The output port port is assumed to be open. This procedure does not close the port.
Parameters port An open output port
strings A list of strings (a rest parameter of the function).
See also Scheme source file write-port-strings
similar function write-string-to-port
Note Notice the order of the parameters compared with write-string-to-port.

Generated: Monday, November 14, 2011, 09:16:30
Generated by LAML SchemeDoc using LAML Version 38.0 (November 14, 2011, full)