Read a file line by line: Difference between revisions

→‎{{header|Euphoria}}: Euphoria example added
(added Fantom example)
(→‎{{header|Euphoria}}: Euphoria example added)
Line 456:
 
See also GNU LGPL (Delphi replacement) [http://www.lazarus.freepascal.org/ Lazarus IDE FreePascal] and specifically [http://wiki.lazarus.freepascal.org/TString_List-TString_Tutorial Lazarus FreePascal Equivalent for TStringList]
 
=={{header|Euphoria}}==
<lang euphoria>constant cmd = command_line()
constant filename = cmd[2]
constant fn = open(filename,"r")
integer i
i = 1
object x
while 1 do
x = gets(fn)
if atom(x) then
exit
end if
printf(1,"%2d: %s",{i,x})
i += 1
end while
close(fn)</lang>
 
Output:
<pre> 1: constant cmd = command_line()
2: constant filename = cmd[2]
3: constant fn = open(filename,"r")
4: integer i
5: i = 1
6: object x
7: while 1 do
8: x = gets(fn)
9: if atom(x) then
10: exit
11: end if
12: printf(1,"%2d: %s",{i,x})
13: i += 1
14: end while
15: close(fn)
</pre>
 
=={{header|Fantom}}==
Anonymous user