Variables and Assignment

As with other programming languages, using variables within SPLASH involves declaring the variables and assigning them values.

For example, the following code declares a variable named eventCount that holds values of type integer (32-bit integers):
integer eventCount;
When you have declared the variable, assign it a value using the := operator:
eventCount := 4;
Use the value of the variable by writing its name:
eventCount + 1
To be concise, you can mix declarations and assignments to initial values:
float pi := 3.14159265358979;
money dollarsPerEuro := 1.58d;
You can also declare multiple variables of the same type in a single declaration, even mixing those with initial values and those without. This declaration describes three variables, all of datatype float, with pi and e set to initial values:
float pi := 3.14159265358979, lambda, e := 2.714;
Variables that begin with non-alphabetic characters or keywords in SPLASH can be turned into variable names with double quotes:
long "500miles" := 500 * 1760;
string "for" := 'for ever';
This feature comes directly from SQL.

Explicit variable declarations make SPLASH into a statically typed language like C and Java. This is different than scripting languages like Perl and AWK, which do not force the declaration of variables. At the cost of more characters, it makes the code easier to maintain and allows optimizations that make the code run faster.