On 12/15/06, Lew Schwartz <[EMAIL PROTECTED]> wrote:

> My current app records numerous logical values and, since I've just run
> out of available bit locations in my integer field,

How many bits are you storing? You can store 31 or 32 bit (depending
on whether you can control sign) in a 4 byte integer field.

> I thought I'd change it to Q(10).

>From what?
>
> Q: Is there a more efficient way to do this?

Use separate logical fields. No coding required. Coding and processing
is typically a lot more expensive than disk space. Unless you have
some other retriction you didn't mention.

If you must use binary storage, use masks to query the values and UDFs
to get and set them.

Example. Hypens added for readability. In binary,

YourVal     = 0000-0000-0000-0000-0000-0000-0000-0000
Yourmask = 0000-0000-0000-0000-1000-0000-0000-0000

(your value is stored in the 15th postiion, counting from the right
and starting at zero, not one)

#DEFINE MySetting15Mask = 2^15

define function IsMyValueSet(valuetotest, mask)
returns BITAND(valuetotest, mask) <> 0

define function SetMyValue(valueholdingsets, mask)
returns BITOR(valueholdingsets, mask)

> Q:How to set an all bits off default value?

Default 0 if they're all define false.
#DEFINE a value if every other one is true:

#DEFINE MyDefault 2^31+2^29+2^27+...

(for extra bonus points, use one #DEFINE for each position and define
all variables off that)

Example:

#DEFINE IsUSCitizen 29
#DEFINE HasClearance 28
#DEFINE HasTSClearance 27
...
#DEFINE HasClearanceMask 2^(HasClearance)

> Q:How to determine field width: len() and fsize() don't work, but using
> afields(...) seems to be ok.

Not sure why you would need to. What is it you're trying to do?

-- 
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com


_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to