Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Write C-Language Code in VFP

Status
Not open for further replies.

VFPIt

IS-IT--Management
Jul 8, 2002
8
US
I need to define a UNION and STRUCTURE to display bit wise information and to pick Low Level and High Level (4 bits each) into different character variables.
 
There really aren't these concepts in VFP. You can write you own functions to pick bits out of data with the BITxxx functions or mathematically using mod and div functions.

There are a couple Structure like classes available on the UT ( in the down loads are that make API calls much easier - they may be useful for what you are trying to do. (Struct.zip is one that has really good documentation.)

Rick
 
There are several very useful functions introduced in VFP6, I believe:

BITAND(), BITOR(), BITXOR(), BITLSHIFT(), BITRSHIFT(), BITSET(), BITTEST(), BITNOT(), BITCLEAR()

To get the high 4 bits of lnByte:

lnHigh4 = BITRSHIFT( lnByte, 4 )
* OR:
lnHigh4 = INT( lnByte / 16 )

To get the low 4:

lnLow4 = BITAND( lnByte, 0x0F )
* OR:
lnLow4 = lnByte % 16

If you need either as a char:
CHR( lnHigh4 )
CHR( lnLow4 )
 
VFPIt

structures in fox does not exist. when using API calss that require a structure, a string is used. the string layout has to occupy the same memory space. there are functions available to assist.

what apis are you calling and what structure do you need.?? Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top