### Read Textfile into a List

This is an example of reading a textfile and store in a list.
Dim tr As TextReader ' textfile to read
Dim trl As List ' textfile content stored in a list
Log("Read Text File: Start")
Try
tr.Initialize(File.OpenInput(File.DirApp, "path to your file"))
trl.Initialize ' do not forget to init the list
trl = tr.ReadList ' read the file content into the list
tr.Close
For i = 0 To trl.Size - 1 ' Loop over the list and log the content (as an example)
Log("Line: " & (i + 1) & "/" & trl.Size & ":" & trl.Get(i))
Next
Catch
Log("Read Text File: Error " & LastException.Message)
If tr.IsInitialized Then tr.Close
End Try
Log("Read Text File: End")
In case the an error occures, the log shows an entry like
(in this case german message as automatically generated by Java):
Program started.
Read Text File: Start
Read Text File: Error java.io.FileNotFoundException: C:\Daten\b4j\OPENSO~1\ROSAND~1\Objects\xyz (Das System kann die angegebene Datei nicht finden)
Read Text File: End

Changed: , Category: Files, File: T6C193M1391.htm, ID: 1391