mmmdreg said:
Hey I can code in VB quite fine but I want to do some stuff with RB. So I was wondering, how do I open and read a text file line-by-line, and can I make custom types (private type foo.. etc etc) as I can in vb. Thanks in advance.
this is straight out of REALbasic's help. this example reads the whole file at once, but there is a TextInputStream.ReadLine that you can Do While NOT TextInputStream.EOF. Here, the GetOpenFolderItem call opens an Open dialog that returns a FolderItem that only allows text files to be chosen. (FolderItems can be of any file type and folders, too, just not in this case.) You can also explicitly set the FolderItem with f=GetFolderItem("yourfile.txt")
Dim f As FolderItem
Dim t As TextInputStream
f=GetOpenFolderItem("text") //file type defined in File Types dialog
If f <> Nil then
t=f.OpenAsTextFile
t.Encoding=Encodings.MacRoman //specify encoding of input stream
EditField1.text=t.ReadAll
t.Close
End if
and yes, you can make custom types, which REALbasic (as well as other languages) refers to as a class. it's just like any other OOP language--you can subclass an existing class or create one from scratch.