SETBIT v,n

Purpose

To set the bit #n of the integer variable v to '1'. n is an integer constant or variable of value between 0 and 15. v may be any integer variable or a system variable such as relay[n], output[n], etc. However, if v is a 32-bit integer, SETBIT will only operate on the lower 16 bits.

Following digital electronics convention, bit 0 refers to the least significant bit (rightmost bit) and bit 15 the most significant bit. (leftmost bit) of the 16-bit integer variable. A quick way to find out the bit position and index of an I/O variable is to open their I/O table and check the "CH:BIT" column. Bit position beyond 9 are represented by hexadecimal number A to F.

Examples SETBIT output[2],11
Comments: output #28 will be turned ON.
(Output channel #2 bit #11 = Output #17 +11 = 28)
See Also CLRBIT, TESTBIT( )

backbutton.gif (507 bytes)  Basic to TBASIC Reference Manual