Using Derived Data Types to Create Names for Types of Value
You can create derived data types so that types of values in your programs have meaningful names.
For example, the value from a pressure gauge is a REAL value. By creating a new data type for this value, you can allocate it a more meaningful name such as PRESSURE.
Example:
- TYPE
- PRESSURE: REAL;
- END_TYPE
As you can see, new data types need to be included in a TYPE definition. The TYPE definition has to come before the PROGRAM definition.
In the example, only one new data type has been created, so there is only one entry within the TYPE definition. However, if you needed to add more new data types, you would add them to the existing TYPE definition—you do not need a TYPE definition for each separate data type.
When you define a new data type, you need to use this format:
- <name of new data type>: <type of value for the data type>;
So, in the example above, the <name of new data type> is PRESSURE and the <type of value for the data type> is REAL.
When you have created a new data type, you can use it in your Logic program. To do this, you need to add it to the list of variables (VAR).