A variable is defined by specifying a name for the variable and assigning a value to it. After a variable is defined, it can be referenced anywhere in a template.

Variable Naming Conventions

Variable names can be up to 80 characters long. They can consist only of letters, numbers, and underscores; no other characters are allowed. Variable names must always begin with a letter and are case sensitive; for example, Thickness, THICKNESS, and thickness are all different variable names.

Variable names cannot be words reserved for Templex statements, implicit variables, or string and mathematical functions or operators. The reserved words are not case sensitive; for example, Time, time, TIME, Date, date, DATE are not valid Templex variables because Time and Date are math functions.

Assign Values to Variables

Values can be assigned to a variable using a constant, an expression, or another variable.

For example:
leaf = 2
coil = 0.5 * sin(alpha/PI)
comment1 = comment0
are all valid assignments. A variable’s data type is determined according to the value assigned to the variable. For instance, if an integer value is assigned to a variable, as in the following statement:
rate = 32

the variable acts as an integer variable. A variable's data type is redefined when a value of a different data type is assigned to the variable.

Every data type has a default output format. The default can be overridden for an individual statement.

For example:
 {i = 12; x = 12.34}
 {i}  {i, %5.2f}
 {x}  {x, %d}
Generates the following output:
12  12.00  12.34  12