Real Basic

Discussion in 'Mac Programming' started by mmmdreg, Oct 10, 2004.

  1. macrumors 65816


    Apr 14, 2002
    Sydney, Australia
    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.
  2. macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
  3. macrumors regular

    Apr 11, 2003
    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.Encoding=Encodings.MacRoman //specify encoding of input stream
    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.

Share This Page