Generated: August 27, 2003, 22:48:02Copyright ©2003, Kurt NørmarkThe local LAML software home page

Reference Manual of the File Reading and Writing Library

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

Master index
Source file: lib/file-read.scm
LAML Version 21.00 (August 27, 2003, PP edition)

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


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


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.


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.


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.


 

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-crIf true, never write a cr (character 13). Ie. never use PC end of line conventions.


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 function does not close the port.

Parameters
suppress-crIf true, never write a cr (character 13). Ie. never use PC end of line conventions.


Generated: August 27, 2003, 22:48:02
This documentation has been extracted automatically from the Scheme source file by means of the Schemedoc tool