TESTBIT (v, n)
Purpose | To return the logic state of bit #n of the variable v. The function returns 1 if the bit is 1, otherwise it returns 0. n is an integer of value between 0 and 15. v may be any integer variable, however, if v is a 32-bit integer TESTBIT will only test the lower significant 16 bits. 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 | TESTBIT (Input[2],3) |
Comments: | To test whether
input #20 is ON (Input channel #2 bit #3 = Input 17 +3 = 20) |
See Also | SETBIT, CLRBIT |