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.
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-cr | If 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 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 | 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 | similar function | write-string-to-port |
Note | Notice the order of the parameters compared with write-string-to-port. |
|