Read a specific line from a file: Difference between revisions

Added FutureBasic example
(Added FutureBasic example)
Line 737:
Console.WriteLine(line)
0</lang>
 
=={{header|FutureBasic}}==
Uses FB's native file$ command that opens a dialog window and allows the user to select the file to read.
<lang futurebasic>
include "ConsoleWindow"
 
dim as long i : i = 1
dim as Str255 s, lineSeven
dim as CFURLRef url
 
if ( files$( _CFURLRefOpen, "TEXT", "Select text file", @url ) )
open "I", 2, @url
while ( not eof(2) )
line input #2, s
if ( i == 7 )
lineSeven = s
end if
i++
wend
close 2
end if
 
if ( lineSeven[0] )
print lineSeven
else
print "File did not contain seven lines, or line was empty."
end if
</lang>
 
Input text file:
<pre>
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
</pre>
Output:
<pre>
Line 7
</pre>
 
=={{header|Go}}==
723

edits