Constant Data

InstallShield 2019 » InstallScript Language Reference

A constant is a named data item with a defined value. InstallShield supports two types of constants:

Predefined constants, such as TRUE and RESET, are part of InstallScript. These constants, which are used as function parameters and return values for built-in functions, cannot be redefined in the script. Attempting to redefine a predefined constant results in a compiler error.
User-defined constants are declared by the programmer as needed for individual scripts. Although a user-defined constant can be redefined after the initial declaration, it is generally not considered good programming practice to do so.

User-defined constants are declared with a #define preprocessor statement. (InstallScript does not support the const keyword for declaring variable constants as the C++ language does.) String constants must be enclosed within quotation marks; numeric constants are defined without quotation marks and contain only numeric characters. Once declared, a string constant can be used anywhere that a string literal can be used. Likewise, number constants can be used anywhere that a numeric literal can be used.

In the following example, a string constant and a numeric constant are declared:

    #define COMPANY_NAME "Example_Company"

    #define MAXCOUNT       1000

A constant name must follow the rules for InstallScript identifiers. By convention, constant identifiers are created with all uppercase characters. InstallScript’s predefined constants follow that convention.

See Also