Article Preview
Buy Now
| Print: | |
| PDF: |
Visual Basic and REALbasic
A Conversion Example
Simulating custom types in REALbasic
Issue: 3.3 (January/February 2005)
Author: Owen Yamauchi
Author Bio: Owen Yamauchi is a freelance programmer who has been programming REALbasic since version F4. He is the Lead Programmer for Domain Softworx, a company that produces developer tools for REALbasic.
Article Description: No description available.
Article Length (in bytes): 7,190
Starting Page Number: 36
RBD Number: 3317
Resource File(s):
3317.sit Updated: Wednesday, January 19, 2005 at 12:04 PM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
In this column, we'll deal with a very useful Visual Basic (VB) code construct that has no equivalent in REALbasic (RB). Custom types allow you to define a new data type, for example (this is VB code):
Private Type Merchandise
Name as String
Price as Double
ItemNo as Long
Available as Boolean
End Type
This essentially creates a new data type called ?Merchandise? with four properties, Name, Price, ItemNo, and Available. If you've been learning from this column, you'll know that a Long in VB is equivalent to an Integer in RB. Once this data type is created, you can access its properties like this:
Dim m as Merchandise
m.Name = ?"REALbasic"?
m.Price = 99.95
m.ItemNo = 1
m.Available = True
Doesn't it look quite a bit like a class in RB? One difference is that you don't need to put this line:
m = New Merchandise
before getting or setting any of the object's properties. Another difference is that a custom type can't have methods. In essence, all it does is hold a collection of primitive data types (like Strings, Longs, Booleans, etc.) together. That makes code easier to read, write, and understand.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|











