SendCreateInstance

 (Available in 01 TS COM - TS_COM_DelegateIDispatch)

Purpose

Invoke a method, Return value as object

Syntax

oObject:=oDelegateIDispatch:SendCreateInstance( #MyObject, #METHOD [,uValue[] ; ...
...+[,...] ] )

Arguments

usymClass
SYMBOL
usymName
SYMBOL
[uParam1..uParamN]
USUAL

Description

Invoke a method, Return value as object. The method 'Send' could be used to return the same value, except the this method will instanciate a object of the specified class ( 'usymClass' ). For the same property the 'Send' method will return an instance of 'TS_DelegateIDispatch'

Returns

OBJECT, Method return value

Example

METHOD CAMethod( [uParm,...] ) CLASS SomeClass
RETURN SELF:SendCreateInstance( #ItemObject, #METHOD [,uParm[] ; ...
...+[,...] ] )

Source

METHOD SendCreateInstance( usymClass, usymName ) CLASS TS_DelegateIDispatch
LOCAL dwPCount AS DWORD
LOCAL symClass AS SYMBOL
LOCAL symName AS SYMBOL
LOCAL uRetVal AS USUAL
LOCAL aArgs AS ARRAY
LOCAL X AS DWORD
   TSTrace Enter usymName
   IF SELF:FInit
      symClass:=usymClass
      symName:=usymName
      dwPCount:=PCOUNT( )
      DO CASE
      CASE dwPCount<2U
         TSTrace Warning "dwPCount<2U" dwPCount
         uRetVal:=NIL
      CASE dwPCount>2U
         aArgs:=ArrayCreate( dwPCount-2U )
         FOR X:=3U UPTO dwPCount
            aArgs[ X-2U ]:=USUAL( _CAST, _GETMPARAM( X ) )
         NEXT
         DO CASE
         CASE Empty( usymClass )
            uRetVal:=SELF:_Send( NULL_SYMBOL, symName, aArgs,  ; ...
           ... ALen( aArgs ) )
         CASE IsClass( usymClass )
            uRetVal:=SELF:_Send( usymClass, symName, aArgs, ALen ; ...
           ... ( aArgs ) )
         OTHERWISE
            TSTrace Warning "!IsClass(usymClass)"
            uRetVal:=NIL
         END
      CASE Empty( usymClass )
         uRetVal:=SELF:_Send( NULL_SYMBOL, symName, NULL_ARRAY ; ...
        ... , 0U )
      CASE IsClass( usymClass )
         uRetVal:=SELF:_Send( usymClass, symName, NULL_ARRAY,  ; ...
        ... 0U )
      OTHERWISE
         TSTrace Warning "!IsClass(usymClass)"
         uRetVal:=NIL
      END
   ELSE
      TSTrace Warning "!SELF:FInit"
      uRetVal:=NIL
   END
   TSTrace Leave usymName
RETURN uRetVal