Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i pass the variant array from CWAI to a Visual Foxpro data type?

First of all, thankyou for any assistance that can be offered.

I am using Visual Foxpro (7 & 9) to write a program to acquire data. Now the old version of the software used Visual Basic as an intermediary to get past this issue with Foxpro and the variant data type array used by the CWAI (or the other controls for that matter).

I need to eliminate the VB portion of the software and move completely to Visual Foxpro, has anyone done any development using Foxpro, rather than VB.

For example, the following code (from a sample) generates the following error "OLE error code 0x80020005: Type mismatch"

Converted from VB

*Call acquire once, and set the XAxis minimum to
*the current time and the maximum to 10 seconds ahead.
THISFORM.cwai1.DEVICE = "1"
THISFORM.cwai1.channels(1).channelstring = "1"
THISFORM.cwai1.configure

DIMENSION laDATA(1,1) AS variant
DIMENSION labin(1,1) AS variant

STORE 0 TO ladata,labin

lo = thisform.cwai1

*Call acquire once
lo.acquiredata(@laDATA,@labin)
LOCAL START AS variant
START = DATETIME()

*Set the XAxis minimum to the current time and the maximum
*to 10 seconds ahead.
THISFORM.cwgraph1.axes(1).setminmax(START, START + lnsec * 10)

*Plot the first set of data.
THISFORM.cwgraph1.ploty(@laDATA, DATETIME(), lnsec * THISFORM.cwai1.scanclock.actualperiod)

*Begin a continuous acquisition.
THISFORM.cwai1.START
0 Kudos
Message 1 of 4
(6,843 Views)
Hi irdi,

The variant you are reading from cwai contains array of double, so you can get the double values from that variant itself.

In addition it could be because of behavior with controls created with the MFC ActiveX template, which is the case for CW controls. The consequence is that FoxPro can write to the controls and read the parameters that are not variants, but cannot read those parameters that are passed as variants. Microsoft has a Knowledge Base on their site (linked below) that discusses this issue:
Microsoft Knowledge Base Q177575: ActiveX Controls Passing Variant* Back to VFP Cause Error

I hope this helps,
Rajiv
Message 2 of 4
(6,831 Views)
Thank you Rajiv, I had not seen that KB post before.
0 Kudos
Message 3 of 4
(6,813 Views)
Hi irdi,

It was little hard to find that KB, Microsoft was hiding it deeper in the search results 🙂

I hope this was able to solve your problem.

Rajiv
0 Kudos
Message 4 of 4
(6,810 Views)