DECLARING METHODS:
------------------
METHODS can be declared as METHOD <cMessage> = <cMethodUDF> when a UDF is
used to process the message <cMessage> OR as code blocks that are
actually a special type of IVar, e.g.
METHOD Display BLOCK {|self| dispbegin(),;
self:show(), self:redefine(),;
dispend() }
This creates a method ::display that has no <cMethodUDF> but is processed
directly by the code block.
You may call the ::display() method with up to 10 parameters ( first
parameter is always self, plus 9 optional more ).
Note: When using BLOCK DATA or METHODS you must reference self as the
first argument in the code block. That is not necessary when using
the INLINE statement (see header file)
INLINE-BLOCK:
-------------------
When declaring INLINE IVars, the self is automatically declared as the
first code block parameter, so, you can write free form, inline code
refering to self as ::, e.g.
DATA nVar AS 0
DATA cVar AS ""
DATA Test( nVal, cVal ) INLINE IF( valtype(nVal) == "N", ::NVar := nVal,), ;
IF( ValType(cVal) == "C", ::CVar := cVal, self)
This is translated into ...
{|self, nVal, cVal| IF( valtype(nVal) == "N", self:NVar := nVal,), ;
IF( ValType(cVal) == "C", self:CVar := cVal,), self }
Make sure you code with a comma separated command list. Last command
will be the return value for the method (self is default).
By default, INLINE statements return Self as the last value in the code
block. Use the NOSELF clause to avoid returning self.
METHOD ALIASING:
------------------------
When aliasing a class using the ALIAS clause at class initialization, all
methods of the class that are overriden by child classes are aliased
using the ALIAS name. If you do not alias the class, the class name is
used instead. So, method oWin:display() will be ::oWinDisplay() in the
child class. Parent methods do not use the same as the child class
methods will keep their original names in the child class, e.g.
CLASS OWIN ALIAS OW // class #1 (parent)
...
...
METHOD MsClick = _oWMsClick
METHOD Display = _oWDisplay
METHOD Hide = _oWHide
ENDCLASS
CLASS DIALOG FROM OWIN // class #2 (child)
...
...
METHOD Display = _oDDisplay
METHOD Hide = _oDHide
ENDCLASS
In this example class DIALOG has a method ::display() and a method ::hide
and also the parent (aliased) methods that can be called using
::owDisplay() and ::owHide(). The child class also contains the parent
method ::MsClick() with the same name as the parent class.
So, you have four ways of calling a parent method from a child class.
(1) using ::super:<methodname> directly.
(2) using ::super(<SuperClassName>):<methodName>
(3) using the aliased overriden method name as demonstrated above.
(4) using ::<SuperAlias>Super:<methodname> e.g. ::oWSuper:Display()
Note:
-----
If you don't provide an ALIAS at Class init, the first 4 chars of
the class name will be automatically the alias for the class e.g.
CLASS TEST1
...
CLASS TEST2 FROM TEST1
// You MUST ALIAS here because ALIAS for both classes will be "TEST"
// so it must be:
CLASS TEST1 ALIAS T1
...
CLASS TEST2 ALIAS T2 // ...or something similar
o Don't forget to ALIAS your Classes. If ALIAS is ommited oObject will use
the first four letters of the class name. If the parent class name
starts with the same four letters as the child class, hell will break
loose and you will be in a world of pain...