Constants

Constants are expressions evaluated and then stored under a symbolic name. Constants are used for values that must be known by a symbolic name but that are not changed by the script. For example, any paths for files used or generated by the script could be assembled at the start of the script and stored under a meaningful name, as shown in this example.

Const Text checkdir = TempDir+"\checkdir";

In this example, the constant checkdir is set to contain the path to the directory checkdir inside the directory contained in the TempDir constant. This TempDir is a local constant that contains the temporary directory for the Document Processor running the script. For more information, see Location constants.

The following keywords cannot be used as constant name: NOT, FI, ELSE, ELIF, OD, TRUE, FALSE. These keywords are case-insensitive.

The following rules apply to all constant names:

  • A constant name consists of any sequence of alphanumeric characters and the underscore (A-Z, a-z, 0-9 and _).
  • A constant name cannot begin with a digit or an underscore.
  • The symbolic names of variables, parameters, and constants must all be unique within their script.
  • The symbolic names of constants are case-sensitive.

  • If a constant is defined within a conditional or repeating statement, the constant is only accessible from its definition until the end of this statement.

Local constants

Every KCM Core Service Script can declare its own constants. These constants are accessible only within the script.

Syntax

Const type name = value;

You can declare variables everywhere in the script. They must be declared before you can actually use them. The value of the constant is evaluated at the moment that it is defined. You can only define a constant once in a script.

The declaration assigns a type to the constant and you can only assign values with that type to the constant. There are three kinds of constants:

  • Text
  • Boolean
  • Number

Values of type Number in KCM Core must lie between -2.147.483.648 and +2.147.483.647.