CountInInit (Available in 00 TS Tools(Base) - TS_Tools_Root0)
Set/reset the 'IsInInit'-flag
SELF:CountInInit( TRUE | FALSE )
One of the first things to do from the 'Init()' method is call this method with 'TRUE' as parameter. The objectstatus is updated and is used to deside when to call the 'New()' method of the object.
When the initialization of the object is finished then this method should be called with 'FALSE' as parameter. After this call the application code can deside to call the 'New()' method by cheking the 'SELF:NeedNew' flag. This method ensures that the object is only allowed to initialize once, and also that the 'New()' method is called once ( form the object highest in the class hirarchy ).
Note: Be sure that calls to this method are symetrical, be sure to first call 'SELF:CountInInit(TRUE)' and then 'SELF:CountInInit(TRUE)' never do the calls in reverse orden and never call this method from 'outside' de object ( e.g. always use SELF as the method sender ).
Hint: Cut and paste this example to be used in your application code.
METHOD INIT( ..., ... ; ...
...) CLASS SomeClass
// Most secure ( and complex ) form of an 'safe' init method
// See also the 'Init()' method documentation
TSTrace Warning "Can not re-init"
SELF:CountInInit( TRUE )
// From here on insert you own initialization code
// It is better not to call any object method/access/assign
// Process the parameters
TSTrace Warning "... parameter error ..."
// At this point all initialization code should be done
SELF:CountInInit( FALSE )
SUPER:INIT( ... ; ...
... , ... )