## Variables and Constants

Variables in the CSL language are used in a similar way to other common programming languages. That is, a variable is a name for a memory location which contains a value that may be modified at runtime. Variables may be either scalar (i.e., a single value) or multi-dimensional (i.e., and array or matrix of dimension 2, 3, 4, 5 or 6). Variables may also represent numeric (i.e., integer or floating point), logical (boolean) or string (character) values.

Variables in the CSL language may be either explicitly or implicitly declared. Implicitly declared variables are defined by virtue of being on the left hand side of an equation. This typically implies that the variable is a scalar floating point value. Alternatively variables may be explicitly declared by using the DIMENSION statement, which assigns a specific dimension and data type to a variable. The dimension keyword is described in detail in the Language Reference.

```
! In the following equation, the variable "a" is
! implicitly declared to be a scalar numeric
a = sin(t*k + p)
! In the following statement, the variable "b" is
! explicitly declared to be a two-dimensional matrix of integers
dimension integer x[2, 3]
```

Constants are used in the CSL language to denote quantities which do not change over the course of a simulation run. Instead, they are set before simulation execution, and are typically used to represent model parameters. Constants are defined via the constant statement. This statement is similar to an explicit variable declaration, but also assigns a default value to the constant.

```
! This statement declares an integer array called "idxvals" and assigns
! the integers 0 through 9 to its elements
constant integer idxvals[10] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
```

The names used for both variables and constants must consist of only letters, numbers and underscores, and must start with a letter. Note that CSL is a case-insensitive language, so that the variables "xpos," "Xpos" and "XPOS" will be treated as the same variable.

Note that variables which are not explicitly initialized in a CSL model are defaulted the the following values by Magnolia:

Logical: False

Real: 5.55555e33

Integer: 55555

String: '' (empty string)