Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Arrays in C dlls
Message
From
22/02/1999 18:18:32
 
 
To
22/02/1999 16:56:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00190091
Message ID:
00190218
Views:
15
>>>>>>>>Off the top of my head I don't know what the structure of a variant array looks like, but someone else probably does.
>>>>>>>
>>>>>>>hmm. Who?
>>>>>>>
>>>>>>
>>>>>>Someone who doesn't believe that VB is the root of all evil...
>>>>>
>>>>>Not me then...
>>>>>
>>>>>I can get the C declarations (will take some digging) will that help you to help me?
>>>>
>>>>Yep - I have a bit (read: lots) better knowledge of what C interfaces look like.
>>>
>>>double THILINKAGE THIbyld(const double *coupon,
>>>int num coupon,
>>>const THIDATE *maturity,
>>>int num maturity,
>>>THIDATE settle,
>>>double price, etc (lists a lot of optional parameters)
>>>
>>>Not sure if this is it or not, to be honest. This was in a pdf file deep in the "C" directory of the library I am evaluating. Does this tell you anything?
>>
>>Yep - the base structure passed contains pointers to an array of doubles - floating point numbers. You can pass a simple pointer to a double in VFP pretty easily; I'll have to look around to see what I can kludge up to pass an array of them.
>
>A function like this added to CLSHEAP would be very helpful.
>

Still looking for a way to create a DOUBLE conveniently.

The breakdown on what you see here might be instructuve.

Where your VB code has a variant array, the C code has a pointer to a buffer of the necessary data type, followed by the number of occurances of the indicated structure. IOW, what the strucuture will ultimately contain will look like:
{4 byte DWORD pointer to a buffer of DOUBLEs}
{4 byte INT number of DOUBLES in buffer}
{4 byte DWORD pointer to a buffer of THIDATEs}
{4 byte INT number of THIDATEs in buffer}
{THIDATE settle}
{DOUBLE price}
etc...
Converting VFP numbers to DOUBLE representation is the stumbling block here; CLSHEAP can easily handle the array by allocating a buffer and using NumToDWORD(nPtrReturnedFromAlloc)+NumToDWORD(nNumElementsInArray) to create the necessary array reference. On return, if a buffer is allocated and handed back, you could extract the array position and the number of elements in the array from the buffer returned by CopyFrom or GetMem() as:

#DEFINE ArrayPos 1 && 1 referenced offset of array in buffer
#DEFINE SizeOfDouble 8 && number of bytes in each array member

nNumFirstDataType = DWORDToNum(SUBST(cMyReturnedBuffer,ArrayPos + 4))
nFirstArrayLoc = DWORDToNum(SUBST(cMyReturnedBuffer,ArrayPos))
cFirstArray = GETMEM(nFirstArrayLoc, nNumFirstDataType * SizeOfDouble)

cFirstArray now gets parsed into indiviudal members.
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