gets
gets channelId ?varName?
Reads one line with no newline. With varName, it puts the line in the variable and gives its length, or -1 at the end of the input. Without varName, it gives the line.
Examples
set f [open t.txt w]; puts $f "a\nb"; close $f; set f [open t.txt]; set n 0; while {[gets $f line] >= 0} {incr n}; close $f; set ngives2
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.