open
open fileName ?access? ?permissions?
Opens a file and gives a channel name. access is r (the default), w (a new file), a (add at the end), r+, w+, or a+, or a list of flags such as {WRONLY CREAT}. permissions is the mode of a new file, 0666 by default. A name that starts with | is a command pipeline, as for exec, with the capability exec. The words -vm VM at the start of the pipeline run it in a guest of ztcl::vm, as exec -vm does.
Examples
set f [open notes.txt w]; puts $f "buy milk"; close $fset f [open notes.txt]; set t [gets $f]; close $f; set tgivesbuy milk
Errors
open nope.txtgives the errorcouldn't open "nope.txt": no such file or directory
Facts
- Capability:
channels. A new interpreter does not have this command. See Limits and capabilities. - Compute cost: one compute unit for the call, and more for the commands that it runs.