► |  | Teachpacks

1 | Ht DP Teachpacks
2 | Ht DP/ 2e Teachpacks

▼ | 2 | Ht DP/ 2e Teachpacks

2.1 | Batch Input/ Output: "batch-io.ss"
2.2 | Images: "image.ss"
2.3 | Worlds and the Universe: "universe.ss"
2.4 | Porting World Programs to Universe

On this page:

read-file
write-file

top ← prev up next →

#### 2.1`` Batch Input/Output: "batch-io.ss"

Matthias Felleisen

( require 2htdp/batch-io )

The batch-io teachpack introduces two functions: read-file and write-file. It facilitates the reading and writing of entire files in one batch.

( read-file f) → string?
f : ( and/c string? file-exists? )

reads the content of file f, located in the samd folder (directory) as the program, and produces it as a string. If f doesn’t exist, the function signals an error.

( write-file f cntnt) → boolean?
f : string?
cntnt : string?

turns cntnt into the content of file f, located in the same folder (directory) as the program. If the file exists when the function is called, the function produces true; otherwise it produces false.
top ← prev up next →