how to get Comate invoke return value?

Share your advanced PureBasic knowledge/code with the community.
john lory
User
User
Posts: 10
Joined: Mon Dec 29, 2008 10:24 am
Location: web

how to get Comate invoke return value?

Post by john lory »

code like:

Code: Select all

flashobject\invoke("CallFunction('" + cmd + "')")
the CallFunction is flash ocx control method,prototype like:

Code: Select all

#  CallFunction
#      [b]retType:  string[/b]
#      params:
#          request
#              in:True  out:False  optional:False  type:string
#  
it have return value, but how can i to get the retrun value :roll:
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Invoke() should not be used to retrieve a property value.

Use GetStringProperty() instead in the case you outline.

btw, why are you posting this in the Tricks 'n' Tips section?
I may look like a mule, but I'm not a complete ass.
john lory
User
User
Posts: 10
Joined: Mon Dec 29, 2008 10:24 am
Location: web

Post by john lory »

srod wrote:Invoke() should not be used to retrieve a property value.

----CallFunction is NOT property,but a METHOD at flash control

Use GetStringProperty() instead in the case you outline.

btw, why are you posting this in the Tricks 'n' Tips section?
---I post this thread at the error section.... :oops: and how to delete this thread?

I add a method to Comate:

Code: Select all

Procedure.s COMateClass_InvokeReturnStringMethod(*this._membersCOMateClass, command$)
  Protected result.i = #S_OK, retVar.VARIANT, result$
  If command$
    result = COMateClass_INTERNAL_Invoke(*this, #DISPATCH_METHOD, #VT_BSTR, retVar, command$)
    If SUCCEEDED(result) And retVar\bstrVal
      result$ = PeekS(retVar\bstrVal, -1, #PB_Unicode)
    EndIf
    VariantClear_(retVar)
  Else
    result = #E_INVALIDARG
  EndIf
  ;Set any error code. iDispatch errors will alreay have been set.
    COMateClass_INTERNAL_SetError(*this, result)
  ProcedureReturn result$
EndProcedure
it is copied from COMateClass_GetStringProperty and minor modification,but it only return String value,It works well :D !!!!
perhapse comate should be added individual invoke method for a variety of types like integer/real/.... :idea:


Comate is great works!! thanks again
john lory
User
User
Posts: 10
Joined: Mon Dec 29, 2008 10:24 am
Location: web

Post by john lory »

in fact ,it is unnecessary that to add new methods, only invoke corresponding type accessing method.
for flash CallFunction method,code like:

Code: Select all

...
rr.s = flashobject\GetStringProperty("CallFunction('" + cmd + "')")
             Debug rr
...
it works
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

John, I am confused here; have you actually read the COMate manual and studied some of the demos?

COMate has methods for returning integer properties, real properties, string properties, object properties... You really do not need to alter the COMate source for this.
I may look like a mule, but I'm not a complete ass.
Post Reply