Page 1 of 1

COMatePLUS; bStr

Posted: Wed Oct 28, 2015 3:23 pm
by HanPBF
Hello,

has someone a simple example how to use the COMate_PrepareStatement.

There is no example in the help showing how to set the bstrVal in the VARIANT structure.

When I call COMateClass_GetObjectProperty with a prepared statement it works with before done:

Code: Select all

COMate_PrepareStatement("AddRibbonBar('TEST-STRING' as STRING)")
But I get an invalid memory access error when trying to change the 'TEST-STRING' after:

Code: Select all

Protected *Par1.VARIANT = COMate_GetStatementParameter(*addRibbonBar, 1)
Simply set \bstrVal to a new memory address for a string does not work.

This line in the COMatePLUS-sources gets the error:

Code: Select all

result = iDisp\Invoke(dispID, ?IID_NULL, #LOCALE_USER_DEFAULT, invokeType, dp, *ret, excep, @uiArgErr)
I guess its because the bstrVal address is not correct so no correct method can be dispatched...

So, any examle with prepare statement and bstrVal avialable?


Thanks a lot in advance,
regards

Re: COMatePLUS; bStr

Posted: Wed Oct 28, 2015 3:27 pm
by HanPBF
o.k. I did a simple PokeS.

debug peeks(*Par1\bstrVal)

Code: Select all

PokeS(*Par1\bstrVal, "STRING-TEST..................................................")
Then it works.

But shouldn't this be dangerous?

Or is the literal string itself internally handled as an address and so no memory overwrite possible...

O.k. address of address; just forgot it...

Re: COMatePLUS; bStr

Posted: Thu Oct 29, 2015 8:02 pm
by mk-soft
Show Include "Variant_Helper.pbi" on COMatePlus packet

Code: Select all


IncludeFile "VariantHelper_Include.pb"

;-Test

Define.variant value, value2, text

V_STR(text) = T_BSTR("Hello World")
Debug VT_STR(Text)

datum.d = T_DATE(Date())

; Test Date
V_DATE(value) = datum
Debug VT_STR(value)
Debug FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss", VT_DATE(value))

; Test LONG to Date
V_LONG(value) = datum
Debug VT_STR(value)
Debug FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss", VT_DATE(value))

; Test Boolean True
V_BOOL(value) = T_BOOL(#True)
Debug VT_STR(value)
Debug VT_BOOL(value)

; Test Boolean False
V_BOOL(value) = T_BOOL(#False)
Debug VT_STR(value)
Debug VT_BOOL(value)


Re: COMatePLUS; bStr

Posted: Fri Oct 30, 2015 7:58 am
by HanPBF
Great!

Thanks a lot for the tip!