Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tax Table Library
Message
From
18/11/2003 14:47:44
 
 
To
18/11/2003 13:04:53
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00851105
Message ID:
00851138
Views:
9
This message has been marked as a message which has helped to the initial question of the thread.
The values don't have to be in 'hex' - you have to create a string whose characters are identical to the binary image of the structure.

If we disregard FoxPro/Mac for a moment then we can assume that we're talking Little Endian here (i.e. x86 CPUs and compatibles). This means that values a arranged in memory with the least significant byte at the lowest address and the most significant byte at the highest. For example, given the following function definitions:
#define OxFF  255

* pack a word
function pw (v)
   return chr(bitand(m.v, OxFF)) + chr(bitand(bitrshift(m.v, 8), OxFF))

* pack a long 
function pl (v)
   return pw(m.v) + pw(bitrshift(m.v, 16))
then you could build a 'structure' containing two 32-bit integers like this:
local cStruc
cStruct = pl(m.tnField1) + pl(m.tnField2)
= ApiFunc(@m.cStruc)
(Note: I wrote the functions when I had my 'brief identifiers' period some five years ago and because they work and because bit-twiddling heavy code actually benefits from having the short identifiers for trivia like pack/unpack I have have not changed them *g*)

If you want to skip the gory details, head on over to the Fox Wiki and read the ApiStructureClass topic. The class in question will handle the bit twiddling for you.
Previous
Reply
Map
View

Click here to load this message in the networking platform