COMatePLUS; bStr

Windows specific forum
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

COMatePLUS; bStr

Post 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
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: COMatePLUS; bStr

Post 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...
User avatar
mk-soft
Always Here
Always Here
Posts: 6340
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: COMatePLUS; bStr

Post 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)

My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: COMatePLUS; bStr

Post by HanPBF »

Great!

Thanks a lot for the tip!
Post Reply