Variables and Integer Math

Integer variables can be declared anywhere in the global block of a template by using the int directive.

Each variable can hold a single 32bit value. You can use a variable anywhere that an integer constant is also legal. Variables can be set either with the set command or with a read (or readln).

There are also a number of predefined variables which contain values of importance to the low-level I/O routines of Import and in maintenance of internal data structures. These variables include: numrecords, numrequests, numcomponents, precision, and maxfind. These variables can be set and used like any other variable but need not be defined by you.

While Import supports variables, it does not support true expression handling. For example, the following statement is invalid.
set a = b * b + c

Import does allow integer variables to be added to each other or to an integer constant, using the sum function. This function (like count and ccount) is only available on the right-hand side of a set statement. In practice, this simple math is all that a template program needs in order to accomplish its task.

The other functions, count, qcount, and ccount, make it possible to count the number of requests, records, or components in a file by tallying up the number of times a pattern appears in a section of a file.