Internal Variables
Each type of Logic program can contain internal variables. These are values that are used by the program but are not written to an item in the database. They are used for:
- Conversions
- Separating long, complex calculations into smaller sets of calculations
- Storing program states.
Unlike direct variables, internal variables are not stored in the database. This means that if the program or the server is reset, the internal variables will reset to their default value (you can stop internal variables from resetting by using the RETAIN keyword, as explained later in this section). As internal variables are not stored, they are not transferred to any standby servers (again, this can be avoided by using the RETAIN keyword).
Internal variables are stored internally so that Logic programs can maintain the internal variables for each execution. For example, if an internal variable is used as a count, the previous value needs to be stored so that the program can use it to determine the next value.
NOTE: Internal variables need to be separated from direct variables, constants and function blocks in the VAR lists. This means that if you have a program that uses constants, internal variables, direct variables, and function blocks, you will have at least 4 VAR lists—1 for constants, 1 for internal variables, 1 for direct variables, and 1 for function blocks.
For information on adding internal variables or using the RETAIN keyword, please refer to the relevant sections: