Jump to content

Read a specific line from a file: Difference between revisions

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

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.