IsInInit

 (Available in 01 TS COM - TS_COM_IUnknown)

Purpose

Test if the 'Init()' method is active.

Syntax

IF SELF:IsInInit

Description

Test if the object is being inited, this flag is only TRUE while the 'Init()' method is being executed. When the 'Init()' method is done the 'IsInited' access will return TRUE.

Example

METHOD INIT( ..., ...  ; ...
...) CLASS SomeICLass
// Most secure ( and complex ) form of an 'safe' init method
// See also the 'Init()' method documentation
   DO CASE
   CASE SELF:IsInited
      TSTrace Warning "Can not re-init"
   CASE SELF:IsInInit
      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
      ..., ... 
      IF lParameterError
         TSTrace Warning "... parameter error ..."
         SELF:InvalidateObject( )
      END
//    At this point all initialization code should be done
      SELF:CountInInit( FALSE )
      IF SELF:IsValidObject
         SUPER:INIT( ... ; ...
        ... , ... )
         IF SELF:NeedNew
            SELF:NeedNew:=FALSE
//          Put your 'PostInit()' code in the 'New()' method
            SELF:NEW( ... ; ...
           ... , ... )
         END
      ELSE
         TSTrace Warning TS_TEXT_GEN_CAN_NOT_INITIALIZE
         SELF:InvalidateObject( )
      END
   OTHERWISE
      TSTrace Warning "This can not happen"
   END
RETURN SELF

Source

ACCESS IsInInit CLASS TS_IUnknown
LOCAL lIsInInit AS LOGIC
   TSTrace Enter
   IF LOGIC( _CAST, _AND( SELF:_ObjectStat1, _OR( TS_OBJSTAT1_ININIT ; ...
  ... , TS_OBJSTAT1_COUNTMASK ) ) )
      lIsInInit:=TRUE
   ELSE
      lIsInInit:=FALSE
   END
   TSTrace Leave
RETURN lIsInInit