Jump to content

Read a file line by line: Difference between revisions

m ({{omit from|GUISS}})
Line 843:
(display line)
(newline))</lang>
 
=={{header|SNOBOL4}}==
 
In SNOBOL4, file I/O is done by associating a file with a variable. Every subsequent access to the variable provides the next record of the file. Options to the input() function allow the file to be opened in line mode, fixed-blocksize (raw binary) mode, and with various sharing options. The input() operation generally fails (in most modern implementations) if the file requested is not found (in earlier implementations, that failure is reported the same way as end-of-file when the first actual read from the file is attempted). You can specify the file unit number to use (a vestigial remnant of the Fortran I/O package used by original Bell Labs SNOBOL4 implementations... in this case, I'll use file unit 20). Accessing the variable fails (does not succeed) when the end of file is reached.
 
<lang snobol4> input(.infile,20,"readfrom.txt") :f(end)
rdloop output = infile :s(rdloop)
end</lang>
 
=={{header|Tcl}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.