# Commands

**On this page**

Command delays are absolute, they’re not related to each other. You can think of them as a timeline, where they don’t affect each other in any way.

**Example 1:** If you set up the first command to trigger at 1000ms and the second command to trigger at 1000ms, both commands will trigger at 1000ms, one right after another (in this case order matters), exactly 1000ms from when the button was pressed.

**Example 2:** If you set up your first command to trigger at 5000ms and your second command to trigger at 2000ms, the second command will be triggered exactly 2000ms from when you pressed the button and then first command will be triggered exactly 3000ms after it (5000ms from when you pressed the button).

**The command delay is superior to the command order, which means that a second command with a shorter delay will be always triggered before the first command with a longer delay.**

**shorter or the same delay**as all the other commands in the IF block. Otherwise the condition will be completely ignored and the block commands will be always executed.

Command delays must be set when you’re creating your button. If you want the delay to be different each time, you can use Statement: Re-enable if and execute the particular command only after the specified condition changes.

String in a programming language is a sequence of characters. It is used to represent text rather than numbers.

Strings are contained within a pair of double quotes, i.e. `"Cat"`

or `"Hello World"`

.

Strings can contain numbers, however you must realize that `"5"`

doesn’t have the value of 5, it has the value of 0, the same as `"a"`

does.

You cannot add strings either, i.e. `"12" + "34"`

isn’t `"46"`

, it’s `"1234"`

. `12 + 34`

is `46`

.

If you wish to convert a string to a number, you can use Math: String to Real command.

`"Hello World"`

.
Operator | Description | Example |
---|---|---|

= | Equal. Real values or strings. Strings need to be wrapped in double quotes. `x = y` |
`x = 7` , `x = "Hello World"` |

+= | Addition. Real values or strings. Strings need to be wrapped in double quote. Same as `x = x + y` |
`7 += 2` = 9 `"Hello" += "World"` = “Hello World” |

-= | Subtraction. Real values only. Same as `x = x - y` |
`7 -= 2` = 5 |

Multiply | Multiplication *=. Real values only. Same as `x = x * y` |
`7 *= 2` = 14 |

Divide | Division /=. Real values only. Same as `x = x / y` |
`7 /= 2` = 3.5 |

DIV | Integer division. Real values only. Same as division, but the remainder is discarded. | `7 DIV 2` = 3 |

MOD | Modulus. Real values only. Returns the remainder of division. | `7 MOD 2` = 1 |

&= | Bitwise AND. Real values only. Same as `x = x & y` |
`7 &= 2` = 2 |

^= | Bitwise XOR. Real values only. Same as `x = x ^ y` |
`7 ^= 2` = 5 |

|= | Bitwise OR. Real values only. Same as `x = x | y` |
`7 |= 2` = 7 |

Cos | Returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians. | `Cos 90` = -0.45 |

Sin | Returns a numeric value between -1 and 1, which represents the sine of the angle given in radians | `Sin 90` = 0.89 |

Tan | Returns a numeric value that represents the tangent of the angle. Tan = Sin/Cos. | `Tan 90` = -2.00 |

You can execute complex math operations in every parameter box, using a mix of variables and real values.

- Each time you want LB to execute any kind of math, you need to wrap the whole sequence in parentheses:
`(some math operation)`

, for example`(variable+3*5+round(variable2))`

or`(variable+10)`

. - If you just want to insert a stack or variable name, it still needs to be wrapped in
`( )`

, for example`(variable)`

. - For stacks you can use
`([x]stackname)`

where x is the position of the stack value. - There is a maximum of 256 characters per input box.

Operator | Name | Example (without parentheses) |
---|---|---|

+ | Add | `3+2` |

- | Subtract | `3-2` |

/ | Divide (including decimals) | `3/2` = 1.5 |

* | Multiply | `3*2` = 6 |

^ | XOR | `3^2` = 1 |

| | OR | `3|2` = 3 |

& | AND | `3&2` = 2 |

$ | Hexadecimal | `$FFF` = 4095 |

round() | Round to nearest integer | `round(3.4)` = 3 |

ceil() | Ceil (Round up) | `ceil(3.4)` = 4 |

floor() | Floor (Round down) | `floor(3.8)` = 3 |

mod | Modulus (division remainder). Space required before and after mod. | `7 mod 3` = 1 or `(7+3) mod (2+4)` = 4 |

div | Divide (no decimals). Space required before and after div. | `7 div 3` = 2 or `(7+3) div (2+4)` = 1 |

Applies to all Statement commands.

Operator | Description | Example |
---|---|---|

== | Equal. Checks whether the variables are equal. Real values or strings. Strings need to be wrapped in “ “. |
`1 == 3` = false `"Hello" == "Hello"` = true |

!= | Not Equal. Checks whether the variables are not equal. Real values or strings. Strings need to be wrapped in “ “. |
`1 != 3` = true `"Hello" != "Hello"` = false |

> | Greater than. Checks whether the variable is greater than the second variable/value. Real values only. |
`1 > 3` = false `3 > 2` = true |

< | Less than. Checks whether the variable is less than the second variable/value. Real values only. |
`1 < 3` = true `3 < 2` = false |

>= | Greater than or equal. Checks whether the variable is greater than or equal to the second variable/value. Real values only. |
`1 >= 3` = false `3 >= 3` = true |

<= | Less than or equal. Checks whether the variable is less than or equal to the second variable/value. Real values only. |
`1 <= 3` = true `3 <= 3` = true |