Read a specific line from a file: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 107: | Line 107: | ||
readLineT=: <:@[ {:: 'b'&freads@]</lang> |
readLineT=: <:@[ {:: 'b'&freads@]</lang> |
||
This is not quite equivalent to the code above as it handles cross-platform line-endings and those line end character(s) are removed from the result. |
This is not quite equivalent to the code above as it handles cross-platform line-endings and those line end character(s) are removed from the result. |
||
=={{header|Liberty BASIC}}== |
|||
We read the whole file into memory, and use 'word$( string, number, delimiter)'. Line delimiter is assumed to be CRLF, and the file is assumed to exist at the path given. |
|||
<lang lb> |
|||
fileName$ ="F:\sample.txt" |
|||
requiredLine =7 |
|||
open fileName$ for input as #i |
|||
f$ =input$( #i, lof( #i)) |
|||
close #i |
|||
line7$ =word$( f$, 7, chr$( 13)) |
|||
if line7$ =chr$( 13) +chr$( 10) or line7$ ="" then notice "Empty line! ( or file has fewer lines)." |
|||
print line7$ |
|||
</lang> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |