INIT

 (Available in 00 TS Tools(Base) - TS_Tools_Root0)

Purpose

Create a 'TS_Root0' instance

Syntax

oRoot0:=TS_Root0{ [#NameOfTheInstance] }

Arguments

usymNameSym
NIL, SYMBOL

Description

This class serves no purpose on its own, the class should be used as a derived from class when defining you own application classes.

Example

CLASS SomeClass INHERIT TS_Root0

METHOD INIT( ..., ...  ; ...
...) CLASS SomeClass
// Less secure ( and simple ) form of an '[less]safe' init method
// It is better not to call any object method/access/assign from
// inside the init method, if needed do this form the 'New()' method.
// From here on insert you own initialization code
// Process the parameters
   ..., ... 
   IF lParameterError
      TSTrace Warning "... parameter error ..."
      SELF:InvalidateObject( )
   END
// At this point all initialization code should be done
   IF SELF:IsValidObject
//    The 'New()' method will be called by the SUPER class
      SUPER:INIT( ... ; ...
     ... , ... )
   ELSE
      TSTrace Warning TS_TEXT_GEN_CAN_NOT_INITIALIZE
      SELF:InvalidateObject( )
   END
RETURN SELF

METHOD INIT( ..., ...  ; ...
...) CLASS SomeClass
// Most secure ( and complex ) form of an 'safe' init method
// It is better not to call any object method/access/assign from
// inside the init method, if needed do this form the 'New()' method.
   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
//    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

METHOD INIT( usymNameSym ) CLASS TS_Root0
LOCAL cAccessTypeList AS STRING
   TSTrace Enter CREATE
   IF LOGIC( _CAST, _AND( SELF:_ObjectStat1, TS_OBJSTAT1_ININIT  ; ...
  ... ) )
      SELF:_ObjectStat1:=_AND( SELF:_ObjectStat1 ; ...
     ... +TS_OBJSTAT1_COUNTVALUE, _NOT( TS_OBJSTAT1_ININIT ) )
      cAccessTypeList:=TS_AccessTypeList( usymNameSym )
      DO CASE
      CASE cAccessTypeList=="U"
//       Do nothing
      CASE cAccessTypeList=="#"
         SELF:_NameSym:=usymNameSym
      OTHERWISE
         TSTrace Warning "Invalid parameter(s), Expected 'U|#', Found '"+cAccessTypeList ; ...
        ... +"'"
         SELF:InvalidateObject( )
      END
      SELF:_ObjectStat2:=_OR( SELF:_ObjectStat2 ; ...
     ... , TS_OBJSTAT2_SELFDESTRUCT_FREEZE )
      SELF:_ObjectStat1-=TS_OBJSTAT1_COUNTVALUE
      IF _AND( SELF:_ObjectStat1, TS_OBJSTAT1_NEWTEST )==TS_OBJSTAT1_NEEDNEW
         SELF:_ObjectStat1:=_AND( SELF:_ObjectStat1 ; ...
        ... , _NOT( TS_OBJSTAT1_NEEDNEW ) )
         IF SELF:IsValidObject
            SELF:NEW( usymNameSym )
         ELSE
            TSTrace Warning TS_TEXT_GEN_CAN_NOT_INITIALIZE
            SELF:InvalidateObject( )
         END
      END
   ELSE
      TSTrace Warning "!LOGIC(_CAST,_And(SELF:_ObjectStat1,TS_OBJECT_STATUS_ININIT))"
   END
   TSTrace Leave
RETURN SELF