Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass a date to a DLL?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00065737
Message ID:
00066026
Views:
38
>>>Peter,
>>>
>>>Thanks a lot. Here is what I found in the header file.
>>>
>>>typedef struct tagDPIDate
>>>{
>>> short jour;
>>> short mois;
>>> short annee;
>>>} DPIDate, FAR * LPDPIDate;
>>>
>>>I removed the text of your message in this answer because I'm using the offline reader and it's plain memo...
>>>
>>>José
>>
>>The length of the string should be 6.
>>
>>After the dll procedure returns you can unpack it by:
>>lnJour = UnpackShort(substr(m.lcStr, 1, 2))
>>lnMois = UnpackShort(substr(m.lcStr, 3, 2))
>>lnAnnee = UnpackShort(substr(m.lcStr, 5, 2))
>>
>>** Here is a VFP procedure that will unpack the datatype short:
>>function UnpackShort
>> lparameters lcStr
>> assert len(m.lcStr) = 2
>> local lnLeft, lnRight
>> lnLeft = asc(left(m.lcStr, 1))
>> lnRight = asc(right(m.lcStr, 1))
>> return iif(bitand(lnRight, 0x80) = 0x80), -1, 1) * bitor(lnLeft, bitand(lnRight, 0x7f))
>
>I understand why you use the BITAND in the IIF. But I really don't get the part after the "*" sign. IMHO, you can't obtain the correct value using this formula.
>
>I would go for the simple one:
>return lnRight * 256 + lnLeft
>
>Of course, you can add the part for the sign, but I don't see how you can have negative values for day, month or year.
>

I just wrote this routine as a general purpose 'short unpacker'. Shorts are signed, so I thought I would include that detail to make the routine more exact. Sometimes I get caught up in the details though! :)
Peter
Peter Stephens
Visual Records, Inc.

Lead Programmer for the general purpose record keeping system Visual Records. Written primarily in VFP 6.0 with a little C++.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform