[futurebasic] Re: fun for thought

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1998 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Tue, 29 Sep 98 13:24:32 +0100
>Jonathan said:
>
>>>A bit-twiddler however will see them as 16 continous bit spaces in memory
>that can contain 16 different boolean states, but they can be even more than
>that!<<
>
>OK, how 'bout this: Suppose I have a whole bunch of variables that are just
>one-bit toggles: on/off, true/false, yes/no. If I wanted to pare unused 
>memory
>to an absolute minimum, could I pack them 16 at a time into a single integer
>variable and pick out the bit I want? For example:
>
>  IF monsterVar% AND 2^n THEN FN doMyStuff(n)
>--
Why not? That's what these toolbox calls are for:
CALL BITSET(bitPtr&,whichBit&)
CALL BITCLR(bitPtr&,whichBit&)
bitState% = FN BITTST(bitPtr&,whichBit&)

I think you will have to use a separate long var to hold the pointer, 
(myBitPtr& = @myBitFlags%) as I couldn't get
  CALL BITSET(@myBitFlags%,whichBit&)
to work. I wonder if adding "#" might do it?
  CALL BITSET(#@myBitFlags%,whichBit&)

Happy twiddling,
 0"0
 =J= a  y
  "