RosettaCodeData/Task/Read-a-specific-line-from-a-file/FreeBASIC/read-a-specific-line-from-a-file.basic
2023-07-01 13:44:08 -04:00

25 lines
554 B
Text

' FB 1.05.0 Win64
Open "input.txt" For Input As #1
Dim line_ As String
Dim count As Integer = 0
While Not Eof(1)
Line Input #1, line_ '' read each line
count += 1
If count = 7 Then
line_ = Trim(line_, Any !" \t") '' remove any leading or trailing spaces or tabs
If line_ = "" Then
Print "The 7th line is empty"
Else
Print "The 7th line is : "; line_
End If
Exit While
End If
Wend
If count < 7 Then
Print "There are only"; count; " lines in the file"
End If
Close #1
Print
Print "Press any key to quit"
Sleep