-
[i]I just copy/pasted this from a text file... too lazy to format it[/i] :D
With all integer value ifchecks, allow the following operators along with the relationals:
| Bitwise ON (if tokenvalue $n 12345 0 | 4 -> ANDs v0 with 4, and is true if non-zero)
& Bitwise OFF (opposite polarity to |)
^ Bitwise Toggle (toggles the value then checks to see if it's non-zero)
For the ON/OFF operators, if multiple bits are given (eg. value of 3), ANY of the bits can
match the condition and be true. To check for ALL being ON or OFF, do each individually.
These would also be usable in token adjust AND in the $[ ] notation as operators.
When used in this fashion, they DO those operations.
| would SET bits.
& would reset them.
^ would do a toggle.
Examples:
token adjust $n 12345 0 & 4
token adjust $n 12345 0 | 2
token adjust $n 12345 0 ^ 6 (toggles both bits 1 and 2)
I could see these used as script flags. The only caveat is that the limit on bit position
is like bit 29 to make sure all values stay within the upper limit of 2000000000.
Knowing the binary values for each bit may be a bit much for some scriptors. Plus when
looking at a combination, it can be difficult to perceive what they are. So here are some
$[] functions for this:
[hex <hex digits>] Range: 00000000 to 3FFFFFFF
[bin <binary digits>] Range: 00000000000000000000000000000000 to 00111111111111111111111111111111
[bit <position>] Range: 0 to 29
[bits <int list>] Range: 0 to 29, in a space seperated list. ORs the bits together.
Examples:
token adjust $n 12345 0 = $[[bit 0]+[bit 10]] (sets it to 1+1024)
token adjust $n 12345 0 = $[[bits 0 10]] (same as above, but shorter)
token adjust $n 12345 0 = $[[hex 401]] (same as above, but using the hex form, not as explicit)
if tokenvalue $n 12345 0 | $[[bit 0]] (checks for odd or just if that bit is on)
if tokenvalue $n 12345 0 & $[[bit 0]] (checks for even or just if that bit is off)