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