Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting List from DLL's
Message
From
12/10/1998 00:44:00
 
 
To
11/10/1998 20:36:39
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00145788
Message ID:
00145824
Views:
32
>Hi : I am trying to communicate with and external device. Everithing is ok but when I am using one function where I am supposed to receive a list of integer values. This is what I am doing :
>
>DECLARE INTEGER _get_template_list@4 IN biidll as nidlist INTEGER @ id
>
>DIMENSION nid(100)
>nid=0
>nAnswer=nidlist(@nid) && by reference
>
>when I check the values of 'nid' (nid(1), nid(2)....) all have the same value which is the first in the list that I was supposed to receive.
>

VFP arrays are not passable to .DLL functions directly; the layout is not a typical C-style array of strucures. You'll probably have to create a buffer in a string and pass that, stripping out and interpreting the list of values yourself afterwards. For example, assuming that the return from the function specified the number of entries in the list, and that the structure returned is an array of 4 byte integers, you would do something like:
DECLARE INTEGER _get-templatelist@4 IN biidll as nidlist STRING id
LOCAL nAnswer, cBuffer, i
nAnswer = 0
cBuffer = REPL(CHR(0), 512)  && enough space for 128 entries to come back
DECLARE anID[1]
nAnswer = nidlist(@cBuffer)
FOR i = 1 TO nAnswer
   DECLARE anID[i]
   anID[i] = DWORD2Num(SUBSTR(cBuffer, 4 * (i-1) +1, 4))
ENDFOR

FUNCTION DWORDToNum
	* Take a binary DWORD and convert it to a VFP Numeric
	LPARAMETER tcDWORD
	LOCAL b0,b1,b2,b3
	b0=asc(tcDWORD)
	b1=asc(subs(tcDWORD,2,1))
	b2=asc(subs(tcDWORD,3,1))
	b3=asc(subs(tcDWORD,4,1))
    RETURN ( ( (b3*256 + b2)*256 + b1) * 256 + b0)
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform