Set or clear one or more bits

dim i,a,b,n asbyte'With the objective functions of variables
a.0 =1' set bit 0
b = a.0 ' read bit 0 and save state in b (0 or 1)
n=3
a.n=1' set bit with number in n (3)'By masking / shifting
a =(1 << 3)' shift the value "1" three Bits to the left and assign the result to a
b = a and0b00010000'mask out bit 4, the state of the bit assigned to b'Get all the bits one after anotherfor i=0to7'go through all the bits (byte)if a.ithen'get bit state'do whateverelse'do otherendifnext'assemble a byte from a number of received bits'With the objective functions of variablesfor i=0to7'go through all the bits'read state lesen, eg. from a function.'Use only the lowest bit of the result.
a.i=(readState(i)and0b00000001)next'with masking and shiftingfor i=0to7'go through all the bits'read state lesen, eg. from a function.'Use only the lowest bit of the result.
a = a or((readState(i)and0b00000001) << i)next