Constants
All numbers and other values in a command or script define constants, these cannot be changed unless the command or script is rewritten. When a script only contains constants, then the result of the script will always be exactly the same.

Constant typeExamples
integers5   -20   0   32000
floating-point numbers3.1415926   2.0   -6592.582   0.0
identifiers (only letters, digits and underscore)pCube1
strings (enclosed between double quotes)"MEL is fun!"   "abcdef012345"   ":<>()&^%ABC"

Variables
A constant can be replaced by a variable, that is a reference to a value that is elsewhere stored and that can be changed between executions of the script or during the execution of a script.

  • A variable has a name, this name van be freely chosen but must be an identifier, that means it must start with a letter (or an underscore _) and consist of only letters and digits (and underscores)
  • The variable name is always preceded by a dollar sign $
     
    Variable declarations
    A variable must be declared before it is used.
  • The declaration of a variable specifies the type of data (or values) it may contain.
  • The declaration may also specify an initial value. If no initial value is specified for a variable, it is given a default value according to the data type specified.

    Variable typeDefault value
    int0
    float0.0
    string""

    int $height = 2;
    polyCube -w 1 -h $height -d 1;

    Variable assignments
    Once a variable is declared, it can be assigned a (new) value using the assignment operator =

    int $width;
    $width = 2;
    polyCube -w $width -h $height -d 1;
    $width = $width + 1;
    polyCube -w $width -h $height -d 1;