Real Basic

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

  1. macrumors 65816

    mmmdreg

    Joined:
    Apr 14, 2002
    Location:
    Sydney, Australia
    #1
    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

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #2
  3. macrumors regular

    Joined:
    Apr 11, 2003
    #3
    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.
     

Share This Page