Normally attributes are collected together in a single integer, or large integer, and you use binary math to evaluate /set them.

Some definitions:
code:
$BLACK=0
$BLUE=1
$GREEN=2
$CYAN=3
$RED=4
$MAGENTA=5
$YELLOW=6
$WHITE=7
$BLINK=8
$BITMASK=&0F

Now these colours can be stored in just four bits(1,2,4,8, or &0F), which means that the foreground and background colours can both be stored in 8 bits, or a byte (short integer).

To get the colour of the foreground assuming $iAttribute is the attribute value of the screen location:
code:
$iForeColour=($iAttribute & $WHITE)
If $iForeColour=$RED
"Foreground is red"
EndIf

To see if the foreground blink/highlight sttribute is set:
code:
If $iAttribute & $BLINK
"Foreground blink is set" ?
EndIf

The background attributes work exactly the same way, except you need to shift the bits before you can compare them. This is simply done by dividing the value by 16.
code:
$iForeColour=($iAttribute / 16) & $WHITE

To set the bits you just work in reverse. To set yellow flashing text on a blue background:
code:
$iAttribute=( $YELLOW |$BLINK ) | ( 16 * ( $BLUE | $BLINK ) )

This is a fast efficient way of storing attribute information, and is how you would do it in 'C'.
It allows you to use a host of programming tricks to simplify and speed up programs. Early games used to use attributes for collision detection, and making all the things that can blow you up high intensity simplifies the code a lot [Smile]

The problem is that bitwise math is not everyone's cup of tea.