Class is a great way to make some things faster by saving the time of producing the code. Wrote it once, use it always. Learn how to create and how to use own Class in REALbasic. Watch it, learn it, enjoy it!
In object-oriented programming, a class is a programming language construct that is used as a blueprint to create objects of that class. This blueprint describes the state and behavior that the objects of the class all share. An object of a given class is called an instance of the class. The class that contains that instance can be considered as the type of that object, e.g. a type of an object of the “Fruit” class would be “Fruit”.
Run REALbasic IDE and go to Project TAB. Click there on Add Class button and select created Class1.

Now go to Property and Value and change the Name from Class1 to cHTTP and add to Super value HTTPSocket. Double click on cHTML Class in Project TAB.

In code editor for this class we will create a new Property, so click Add Property and in Declaration type Data in As type String.

Our next step will be creating a new Method. Click on Add Method button next to Add Property and enter for Method Name downloadHTML. Now insert this code below.
1 2 3 | Data = Me.Get ("http://tutspolis.com", 3 ) Me.Close |
The HTTPSocket has got a option called Get with will simply in this case get the html code of indicated URL. Our class will download for us the HTML from tutspolis.com.
Now in GUI builder we will have a new control called cHTML. We can simply drag and drop it to our Window. To try out our new class add to the Window controls TextArea and PushButton. Double click on PushButton and enter the code:
1 2 3 4 | Dim tuts As new cHTML tuts.downloadHTML // get the html code TextArea1.Text = tuts.Data // display it in TextArea control |
When we will press PushButton, TextArea will fill up with HTML code of tutspolis.com home page. You can now for example render the code, modify it or get only some important for you information. It can be also done in class cHTML on other Method.