This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
manual:Calculations [2017/09/06 01:29] peternlewis [Operators] |
manual:Calculations [2018/05/16 22:07] JMichaelTX |
||
---|---|---|---|
Line 26: | Line 26: | ||
| ternary operator (?) | a=b ? 3 : 4 | | | ternary operator (?) | a=b ? 3 : 4 | | ||
| bitwise or (%%|%%), bitwise and (%%&%%) and bitwise xor | operators | | | bitwise or (%%|%%), bitwise and (%%&%%) and bitwise xor | operators | | ||
- | | comparison operators (<, ≤, = (or ==), >, ≥, ≠) | compare for (in)equality and return 0 or 1 | | + | | comparison operators (<, ≤, =, >, ≥, ≠) | compare for (in)equality and return 0 or 1 | |
| shift operators (≪, ≫) | shift a number left or right | | | shift operators (≪, ≫) | shift a number left or right | | ||
| addition operators (+, -) | add or subtract | | | addition operators (+, -) | add or subtract | | ||
Line 35: | Line 35: | ||
| numbers and variables or array accesses (5,$5A,0x50,8#007,Variable,Variable[5]) | identifiers and values | | | numbers and variables or array accesses (5,$5A,0x50,8#007,Variable,Variable[5]) | identifiers and values | | ||
| unary postfix operators (!,%,° (Option-Shift-8)) | factorial, percent, degrees | | | unary postfix operators (!,%,° (Option-Shift-8)) | factorial, percent, degrees | | ||
+ | |||
+ | You can use either `=` or `==` (v8+) for testing for equality. | ||
Operators and functions must be in uppercase to minimize conflict with variables. | Operators and functions must be in uppercase to minimize conflict with variables. | ||
Line 60: | Line 62: | ||
* myWindow.y | * myWindow.y | ||
* myWindow.Top | * myWindow.Top | ||
+ | |||
+ | ===== Variable Array Access ===== | ||
+ | |||
+ | If a variable contains a sequence of numbers separated by comma (,) then you can access that variable using array notation (eg `MyVar[5]`). So if variable MyVar has a text value of `10,20,30,40,50,60`, MyVar[5] will return 50. | ||
+ | |||
+ | The index is itself an expression, so it can be arbitrarily complex. | ||
+ | |||
+ | Indices are 1-based, so MyVar[1] is the first element. If the index is 0, the size of the array is returned (so MyVar[0] would be `6`). If the index is less than zero, the array is indexed from the end (so MyVar[-5] would be `20`). | ||
===== Variable Dot Notation ===== | ===== Variable Dot Notation ===== | ||
Line 78: | Line 88: | ||
The Variable Name and Dot reference are case insensitive. | The Variable Name and Dot reference are case insensitive. | ||
- | |||
===== Text Fields ===== | ===== Text Fields ===== | ||
Line 109: | Line 118: | ||
SCREEN(Internal,Left,10%) | SCREEN(Internal,Left,10%) | ||
</code> | </code> | ||
+ | |||
+ | --- | ||
+ | |||
+ | **KeyWords:** MOD, Modulo |