Topic: DMD0499 Using Constant Values |
|
Constants - values that do not change throughout the program execution - can be used in most places where memory elements can be used. Constant values can even have Nicknames; these are called symbolic constants.
One of the places constant values are commonly used are as instruction parameters, for example:
Constants can also be used in some of the utilities used for programming and debugging, for example: Find, Trend View, etc.
|
|
How to Specify the Data Format of a ConstantConstant values can be entered as Decimal, Hex, Real, or Octal values. The data format specifier can be manually entered with the value.
Alternatively, clicking the 'three dot box' to the right of a parameter field will open the Element Picker, if the parameter allows constants, you can expand the Constants group which contains the list of the constants - or ranges of constants - that are acceptable for this parameter field. Clicking a constant range will select the first value in that range with the appropriate format specifier.
If the programming session is online and rung status is ON, the right-click menu for a parameter filed can be used to select or change the display format of a constant value. If the instruction is a relational contact, using this method to change the format of the constant will change the format of both parameters.
|
|
Symbolic ConstantsThe Element Documentation Editor allows for the creation of symbolic constants for use in the project. These are constant values represented by text instead of the literal numeric value. The use of appropriately named symbolic constants can clarify the intent of the code, and additionally, if a specific value needs to be changed, reassigning a symbolic constant value once is more efficient and less error prone than replacing every instance of the value.
In the Documentation editor, the Element column will display 'Symbolic Const', the Nickname field will display the name of a symbolic constant and the Extra Info field will contain the constant value.
|
|
See Also:
User-Created Data Blocks and Structures
Assignment Operations and Instructions
Using Constant Values
|
|
Related Topics:
|
|