There's many definitions of a "method," for lack of a better word, that's
what I'm using to describe the methods CONSTRUCTOR, CREATE and WITH.
Alone they serve no purpose, but you'll learn what each does, and how to
use them here.
CREATE .. END CREATE
Using CREATE is exactly like using DIM
CREATE Form AS QForm
END CREATE
'' or
DIM Form AS QForm
However, the CREATE method offers more. It can save you typing, and also make
your code look cleaner by embedding CREATEs (refer to Chapter 5).
Any code you type inbetween the CREATE .. END CREATE method is automatically
bound to that object. Since there's no point in regurgitating what was already
mentioned, please refer to Chapter 5 for some examples.
WITH .. END WITH
The WITH construct is to provide the developer an easier way to reference
properties, methods, and events of certain objects. Basically what it does is
save you a lot of typing:
Form.Caption = "Hello"
Form.ShowModal
'' Using WITH
WITH Form
.Caption = "Hello"
.ShowModal
END WITH
You can also embed WITH .. END WITH statements:
Something.Another.Caption = "Hello"
'' Using WITH
WITH Something
WITH Another
.Caption = "Hello"
END WITH
END WITH
As you can see, the embedded WITH statement inherits the previous declaration.
The period at the front tells the compiler to bind that variable to the WITH
declaration. Anything which doesn't start with a period won't be bound, don't
worry, decimal numbers won't be bound.
CONSTRUCTOR .. END CONSTRUCTOR
This method is only used inside a TYPE declaration when you're defining
your own objects. It will give default values to your properties whenever
your component is created (DIMmed).
TYPE NewObject EXTENDS QObject
Left AS INTEGER
CONSTRUCTOR
Left = 50
END CONSTRUCTOR
END TYPE
There's nothing to it, it's much like the CREATE method, except our object
in this case is NewObject.