Read a specific line from a file: Difference between revisions

Changed program to use a procedure which returns the line.
m (→‎{{header|Phix}}: added syntax colouring the hard way)
(Changed program to use a procedure which returns the line.)
Line 1,249:
=={{header|Nim}}==
 
<lang nim>varimport strformat
line: TaintedString
f = open("test.txt", fmRead)
 
proc readLine(f: File; num: Positive): string =
for xn in 0 1.. 6num:
try:
line = readLine f
result = f.readLine()
except EIOEOFError:
echo "Not 7 lines in file"</lang>
raise newException(IOError, &"Not enough lines in file; expected {num}, found {n - 1}.")
 
let f = open("test.txt", fmRead)
echo f.readLine(7)
f.close()
</lang>
 
=={{header|OCaml}}==
Anonymous user