[futurebasic] Re: [FB] BITTST

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Mel & Carol Patrick <mel@...>
Date: Fri, 21 May 1999 21:19:10 -0700
>This is one of those peculiar FB implementations of a Toolbox function.  In
>BITTST (and many other Toolbox routines), the OS wants the parameter to be the
>_address_ of a data structure, but FB wants the parameter to be the data
>structure itself (in the form of a variable).  When you pass a variable (in
>this case, "a&") to the function, FB then passes the _address_ of the variable
>(essentially, "@a&") to the OS Toolbox.
>Internally, when BITTST gets an address, it looks at the bits of whatever is
>located at that address.  This means that FB's BITTST(a&, i&) will return a
>bit in the variable a& (not a bit in tmp$).
>To tell FB, "No, no, I don't want you to pass the _address_ of a&; I want you
>to pass the _contents_ of a&," you put a "#" in front of the expression:
>  BITTST(#a&, i&)
>Since the contents of a& is a pointer to the first byte pass the beginning of
>tmp$, the above gets you what you want.
>In a nutshell: for certain (not all!) FB Toolbox implementations:
>  TheToolboxRoutine(var,...)     -> FB passes the address of var to the
>  TheToolboxRoutine(#longExpr,...)   -> FB passes longExpr to the Toolbox

I went and looked up my code for BITTST too, and if you bit test 0, its not
BIT 0, its the offset from address (in bits). So FN
BITTST(bytePtr&,bitNum&) where bitNum& offset looks like this :

0|1|2|3|4|5 etc offsets-->

So keep that in mind if you are testing for a specific bit. In which case
it would be better to use AND or BIT in FB.

Mel Patrick