Default Values for Structured Data Types
The format for defining a default value for a structured data type is:
TYPE <Structured Data Type Name>:
STRUCT
<Value Name>:<Value Type>:=<Default Value>;
<Value Name>:<Value Type>:=<Default Value>;
<Value Name>:<Value Type>:=<Default Value>;
END_STRUCT;
END_TYPE
VAR
<Variable Name>:<Structured Data Type Name>;
END_VAR;
Example:
TYPE
TEMPERATURE:REAL;
END_TYPE
TYPE
TemperatureControl:
STRUCT
Current: TEMPERATURE;
SetPoint: TEMPERATURE:=30.1;
Update: DATE_AND_TIME:= DT#1970-01-01-00:00:00;
Status: ControlStatus;
Desc: STRING:= 'Current Temperature';
END_STRUCT;
END_TYPE
VAR
Temp1:TemperatureControl;
END_VAR;
In this example, the user defined data type is defined in the first TYPE section, the structured data type is defined in the second TYPE section, and the default values are defined in the STRUCT section. The default values are specified as part of the structured data type definition.
If values were defined for Current, SetPoint, Update, Status, or Desc in the VAR list, the values in the VAR list would override the default values set in the data structure.