A constant in UnrealScript is basically an alias name for a certain value. Whenever a constant is used in code, it is replaced with the actual value it stands for.
Syntax
Constants can be declared both at class and function Wikipedia:scope, but are always globally available in the entire class and all of its subclasses. A constant is declared with the following syntax:
const name = value ;
The name must be a valid identifier, i.e. may only contain the letters 'A' to 'Z' in upper and lower case, the digits '0' to '9' and the underscore character '_' and it must not start with a digit. The value can be any constant expression (see below).
Constant Expressions
A constant expression can be a literal (such as numbers and strings), the name of a constant, or one of the special expressions ArrayCount(arrayname) and (starting with UnrealEngine 3) enumname.EnumCount. Note that EnumCount is not recognized as constant expression in earlier engine generations.
Constants used in constant expressions must be declared declared before they are used. Here "before" may be earlier in the same class or in any class parsed before the current class. This explicitly includes all parent classes of this class, all classes specified in the current class's DependsOn modifier(s) and all their parent classes and all loaded classes in packages compiled before the package of the current class.
Constant expressions can not only be used as the value in constant declarations, but also as the array index in variable and parameter declarations.
See Also
- UnrealScript
- Class / Interface
- Variable Syntax