Wow! Big subject! [Eek!]

You know that a number can be represented in binary form, and each binary digit ("bit") can be 1 or 0. Well, these can be used as simple yes/no flags.

For instance:
1 = 0001
2 = 0010
3 = 0011
...
15= 1111

You can assign a meaning to each bit.
1 = 0001 = yellow
2 = 0010 = blue
4 = 0100 = car
8 = 1000 = train

To test if one or more bits are set you use a boolean AND (&). For example:
code:
$Transport=5
If $Transport & 1 "Vehicle is YELLOW" ? Endif
If $Transport & 2 "Vehicle is BLUE" ? Endif
If $Transport & 4 "Vehicle is a CAR" ? Endif
If $Transport & 8 "Vehicle is a TRAIN" ? Endif

Will give you:
quote:
Vehicle is YELLOW
Vehicle is a CAR

You may also combine the tests:
code:
If ($Transport & 3)=3 "Vehicle is Green!" EndIf

If you need more explanation try searcing the net for "boolean", "truth tables" and "logic gates".

EDIT: Glad I spotted that error before anyone else...

[ 05 March 2002, 18:14: Message edited by: Richard Howarth ]