STRUCT_BLOCK |
Top Previous Next |
A STRUCT_BLOCK is a user-defined composite type. Struct blocks are an extremely useful facility to group variables as in this example:
STRUCT_BLOCK sbBufferPDU
The biggest advantage of the STRUCT_BLOCK is found when writing data of different types to the serial port, PDU message, or file system. Instead of writing the data types individually, they can be grouped in a STRUCT_BLOCK, and the device sees it as one variable.
STRUCT_BLOCK sbGpsData
To access the members of a STRUCT_BLOCK, the same syntax as used with a FUNCTION_BLOCK is used. For example:
gpsData.speed := 100;
To send the data through a serial channel:
serSendData(port:=1, data:=ADDR(gpsData), size:=SIZEOF(gpsData));
Note: Care must be taken when working with a STRING inside a STRUCT_BLOCK as the actual string is not contained in the variable (see string). |