Input loop: Difference between revisions

m
mNo edit summary
imported>Arakov
 
(2 intermediate revisions by 2 users not shown)
Line 1,290:
 
=={{header|Elena}}==
ELENA 46.x:
 
Using ReaderEnumerator
Line 1,299:
public program()
{
ReaderEnumerator.new(File.assign:("file.txt")).forEach(printingLn)
}</syntaxhighlight>
Using loop statement
Line 1,306:
public program()
{
using(var reader := File.assign:("file.txt").textreader())
{
while (reader.Available)
Line 3,051:
fn main() {
mut ay_view_content := []string{}
file := '"./input.txt'"
// check if file exists
if os.is_file(file) == false {
print('"Error: "'${file}"' not found'")
exit(-1)
}
ay_view_content << os.read_lines(file) or {print(err) exit(-2)}
for line in ay_view_content {
if line !=''"" {println(line)}
if line ==''"" {println('"Found blank line!'")}
}
}
Line 3,066:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">import "io" for File
 
File.open("input.txt") { |file|
Anonymous user