Technical data

Appendix
27.3 Data Types and Parameter Types
Programming with STEP 7
Manual, 05/2010, A5E02789666-01 607
Assigning Initial Values for a User-Defined Data Type
If you want to assign an initial value to every element of a user-defined data type, you specify a
value that is valid for the data type and the name of the element. You can, for example, assign the
following initial values (to the user-defined data type declared in the above figure):
Amount = 100
Original_data = B#16#0)
Control_code = 'C'
Temperature = 1.200000e+002
End = False
If you declare a variable as a UDT, the initial values of the variables are the values you specified
when you created the UDT.
Saving and Accessing Data in a User-Defined Data Type
You access the individual elements of a UDT. You can use symbolic addresses (for example
Stack_1.Temperature). You can, however specify the absolute address at which the element is
located (example: if Stack_1 is located in DB20 starting at byte 0, the absolute address for amount
is DB20.DBW0 and the address for temperature is DB20.DBD6).
Using User-Defined Data Types as Parameters
You can transfer variables of the data type UDT as parameters. If a parameter is declared as UDT
in the variable declaration, you must transfer a UDT with the same structure. An element of a UDT
can, however, also be assigned to a parameter when you call a block providing the element of the
UDT corresponds to the data type of the parameter.
Note
If you call a block created in the S7-SCL programming language that contains a UDT parameter in the
program editor, this can result in a type conflict. You should therefore avoid using blocks created in
SCL if you use UDTs.