Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieving safearray BSTR** value from COM call in VFP
Message
From
17/07/2003 14:23:47
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, United States
 
 
To
16/07/2003 18:56:09
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00810883
Message ID:
00811191
Views:
49
If you need to pass a SafeArray of bytes by reference in VFP 7, you're out of luck, at least as far as native VFP is concerned. VFP 7 and before cannot create a SafeArray of VT_UI1 and pass BY_REF, only BY_VAL, which does no good at all. They finally fixed this in VFP 8. Get VFP 8 and use:

DIME MyArray[n] as BYTE
COMARRAY(MyCOMObject,10)
MyCOMObject.Method(@MyArray)
display memory like MyArray && Should be properly sized and filled by the COM object

I don't have access to my code that does this but working from memory, the above will get you close. The bottom line is that VFP 7 can't do this. A passed array will be 8 byte variants, if I remember correctly, instead of an array of bytes that the object probably wants.

Gary

>I can't figure out how to get the right return values of a a COM object from Visual Foxpro 7.0 SP1. I'm using Quickbooks 2003 Pro with Quickbooks SDK 2.1.
>
>Here's Intuit's description of the COM method:
>-------------------------------------------------
>HRESULT QBXMLVersionsForSession([in] BSTR ticket,
> [out, retval] SAFEARRAY (BSTR)** ppsa);
>
>Returns an array containing the version numbers of the DTDs supported by the Request Processor. Note that this information may be different from the information returned by a Host Query request, as described in the Concepts Manual. HostQuery returns the complete list of all qbXML versions supported by the currently open connection, which is usually the information your application will require.
>
>Parameters
>ticket
>
>Handle for this session (returned by BeginSession).
>
>ppsa
>
>Address of a variable to receive a pointer to an array of binary strings that specify the versions of the qbXML specification that are supported by the QuickBooks Request Processor. For example, the array contains 1.0, 1.1, 2.0, and 2.1 if your application is using the Request Processor from the latest version of QuickBooks, U.S. edition. It contains "CA2.0" if it is using the Request Processor from the Canadian edition of QuickBooks version 2.0.
>--------------------------------------------------
>
>I'm not real familiar with visual basic, but here's some code from the hostqueryinformation vb example that seems to work. The problem is I need to do this in VFP not VB.
>
>-----VB CODE-------------------------------------------------------
> Dim strVersions() As String
> Dim strAllVersions As String
>
> strVersions = qbXMLCOM.QBXMLVersionsForSession(strTicket)
> strAllVersions = strVersions(LBound(strVersions))
>
> If LBound(strVersions) < UBound(strVersions) Then
> For i = LBound(strVersions) + 1 To UBound(strVersions)
> strAllVersions = strAllVersions & " , " & strVersions(i)
> Next
> End If
> --------------------------------------------------------------------------
>
>The problem is that I need to do this from Visual Foxpro 7.0 SP1, which does not have support for arrays that are anything but 1 based. I've tried to call this using this code
>
>dimension testarray[50]
>testarray[1]="nothing in this array"
>
>* then I try this and there is no error but nothing is placed into allversions
>loQb.QBXMLVersionsForSession(lcticket,@allversions)
>? allversions[1]
>? allversions[2]
>
>* or I try this and there is no error but nothing is placed into allversions
>loQb.QBXMLVersionsForSession(lcticket,allversions)
>? allversions[1]
>? allversions[2]
>
>Thanks in advance for any ideas any of you might have.
>
>From: Ed
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform