The following guidelines show how to write MathScript code in the MathScript Node or in a user-defined MathScript function.
White spaces or commas separate array elements. Semicolons separate rows of an array. For example,
[1 2 3]
[1, 2, 3]
define an array with three columns, each with one value, and
[1; 2; 3]
defines an array with three rows, each with one value.
Variable names cannot begin with an underscore, a white space, or a digit.
Periods separate decimals.
Ranges define vectors by start value, increment, and stop value. The syntax for ranges is start: [step:] end. Start, step, and end are constant scalar numbers of either integer or floating-point data types, or characters. MathScript uses a step size of 1 by default. If an input is a character data type, the output is also a character data type.
Either i or j represent the imaginary unit equal to the square root of -1.
Comment lines begin with a
Semicolons or commas separate several commands in one line.
Three dots at the end of a line continue a command on a new line.
MathScript uses short-circuit evaluation to evaluate compound logical expressions. For example, the command if 0 == 0 || abs(a) == 1 does not execute abs(a) because the first part of the expression already is TRUE. Similarly, the command if 0 ~= 0 && abs(a) == 1 does not execute abs(a) because the first part of the expression already is FALSE.