Input loop: Difference between revisions

Add LIL
(Add LIL)
Line 1,336:
close #f
end </lang>
 
=={{header|LIL}}==
From the canread.lil sample that ships with LIL.
 
<lang tcl>#
# canread test (note that canread is not available in LIL/FPLIL itself
# but provided by the command line interfaces in main.c/lil.pas)
#
# You can either call this and enter lines directly (use Ctrl+Z/Ctrl+D
# to finish) or a redirect (e.g. lil canread.lil < somefile.txt)
#
# Normally this is how you are supposed to read multiple lines from
# the standard input using the lil executable. For an alternative way
# that uses error catching via try see the eoferror.lil script.
#
 
set count 0
while {[canread]} {
readline
inc count
}
print $count lines</lang>
 
{{out}}
<pre>prompt$ lil canread.lil <canread.lil
19 lines</pre>
 
=={{header|Logo}}==
Anonymous user