Readable.EOF

From Xojo Documentation

Method

Readable.EOF() As Boolean

Supported for all project types and targets.

Returns True when the read reaches the end of the stream.

Sample Code

This code reads the rows and columns of data from a tab-delimited text file into a ListBox:

Dim f As FolderItem
Dim textInput As TextInputStream
Dim rowFromFile, oneCell As String

f = GetOpenFolderItem("text/plain") // defined as a FileType
If f <> Nil Then
textInput = TextInputStream.Open(f)
textInput.Encoding = Encodings.UTF8
Do
rowFromFile = textInput.ReadLine
If ListBox1.ColumnCount < CountFields(rowFromFile, Chr(9)) Then
ListBox1.ColumnCount = CountFields(rowFromFile, Chr(9))
End If

ListBox1.AddRow(NthField(rowFromFile, Chr(9), 1))
For i As Integer =1 To CountFields(rowFromFile, Chr(9))
oneCell = NthField(rowFromFile, Chr(9), i)
ListBox1.Cell(ListBox1.ListCount - 1, i - 1) = oneCell
Next
Loop Until textInput.EOF
textInput.Close
End If

This example reads each pair of bytes from a file and writes them in reverse order to a new file. The user chooses the source file using the Open-file dialog box and saves the new file using the Save as dialog box. The EOF property is used to terminate the Do loop.

Dim readFile As FolderItem = GetOpenFolderItem("text")
If readFile <> Nil Then
Dim ReadStream As BinaryStream = BinaryStream.Open(readFile, False)
ReadStream.LittleEndian = True
Dim writeFile As FolderItem = GetSaveFolderItem("", "")
If writeFile <> Nil Then
Dim writeStream As BinaryStream = BinaryStream.Create(writeFile, True)
writeStream.LittleEndian = True
Do Until ReadStream.EOF
writeStream.WriteInt8(ReadStream.ReadInt8)
Loop
writeStream = Nil
End If
readStream = Nil
End If