Introduction | Language Structure | IB Statements | File System | Comet 32 Runtime | Index |
| Discussion: | The TESTBIT function returns the value of a specified bit in a string expression. |
| Syntax: | Result = TESTBIT(string-expression, bit-location [,EXCP=label]) Where: Result is the value (0 or 1) of the bit at the specified bit-location. String-expression is a string value encoded in binary form. Bit-location is a numeric value specifying the bit that is to be set. Bits are 0-based and are ordered according to the following scheme: If the string-expression contains 8 bits, they are ordered: 7 6 5 4 3 2 1 0 If the string-expression contains 16 bits, they are ordered: 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 If the string-expression contains 24 bits, they are ordered: 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 An exception occurs if the program attempts to test a bit beyond the declared length of the string-expression. |
| Example: |
A$ = @7FA5@ FOR I = 0 TO 15 Result = TESTBIT(A$,I,EXCP=9999) Print Bit;I;is;Result NEXT I |