Assignments

The general syntax for an assignment is

variable = (expression)

The (expression) may consist of an explicit value, such as 5, or a variable name containing some preassigned value, or a complex mathematical expression involving functions, constants, and variables. In all cases, the expression on the right side of the equal sign is evaluated, and the result is assigned to the variable designated on the left.

The simplest form of an assignment is where the expression is a fixed value, such as:

x = 5

There are several important things to note in this command. First, no declaration of variables is required. This means "x", which is called a variable, did not need to exist before the value of 5 was assigned to it. If "x" had already been assigned a value, it would now be reassigned. Second, no special symbol is required to terminate a command, such as ";" in C. Because of this, each ZPL command must be on a line by itself.

Here are some examples of assignments with expressions:

x = SQRT(5)
y = SINE(x)
z = SQRT(x+5*(7-x))

The functions SQRT (square root) and SINE (sine) are built in to ZPL. There are many of these functions, all of which are defined in "Numeric functions". Note that ZPL is not case-sensitive; SQRT() and sqrt() are the same function. This documentation will use the convention of capital letters for functions and keywords, and lower case for everything else.

There are also string assignments as described in "String variables".

Next: