Read a specific line from a file: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring the hard way) |
(Changed program to use a procedure which returns the line.) |
||
Line 1,249: | Line 1,249: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
<lang nim> |
<lang nim>import strformat |
||
line: TaintedString |
|||
⚫ | |||
proc readLine(f: File; num: Positive): string = |
|||
for |
for n in 1..num: |
||
try: |
try: |
||
line = readLine f |
|||
result = f.readLine() |
|||
except |
except EOFError: |
||
echo "Not 7 lines in file"</lang> |
|||
raise newException(IOError, &"Not enough lines in file; expected {num}, found {n - 1}.") |
|||
⚫ | |||
echo f.readLine(7) |
|||
f.close() |
|||
</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |