Script Operators.

BRAIN supports some basic operations on variables. Currently, the following operators are supported:

Operator
Description
Type
+
Addition
Numeric
-
Subtraction
Numeric
*
Multiplication
Numeric
/
Division
Numeric
=
Equal to
Numeric
!=
Not Equal to
Numeric
>
Greater than
Numeric
>=
Greater than, or Equal to
Numeric
<
Less than
Numeric
<=
Less than, or Equal to
Numeric
OR
Conditional Or
Boolean
AND
Conditional And
Boolean
&
Concatenate
String
CONTAINS
Contains
String




Examples:

The following script adds two numeric variables together:
$number1=10
$number2=5
$result=$number1+$number2
Say $number1 plus $number2 equals $result



The following script subtracts one numeric variable value from another:
$number1=10
$number2=5
$result=$number1-$number2
Say $number1 minus $number2 equals $result



The following script multiplies two numeric variables together:
$number1=10
$number2=5
$result=$number1*$number2
Say $number1 multiplied by $number2 equals $result



The following script divides two numeric variables:
$number1=10
$number2=5
$result=$number1/$number2
Say $number1 divided by $number2 equals $result



The following script adds two string variables together (with a space in between):
$string1=My
$string2=Robot
$result=$string1&string2
Say $string1 concatenated to string2 is $result



The following script checks to see if a string contains a word:
$string="Welcome to the world of Robotics."
if $string CONTAINS Robotics then SAY Word found else SAY word not found.



The following script performs a boolean operation:
$number1=10
$number2=5
if $number1 >= $number2 then SAY $number1 is greater than or equal to $number2



Expressions can be nested. For example:
$result=($value1*$value2)+$value3


lightbulb Note: Currently operators only apply to variables. You cannot apply operators to numbers or strings that are not variables.

For example, the following scripts do not work.

Say 10+5 is 15.

Say Hello & " " & World.

Instead, use the syntax illustrated above.