ADSLOGDINT
This function issues when called a message box holding a specifiable text on the screen, and writes an entry into the system’s log.
Since a PLC program is cyclically processed, it is necessary for an item such as a message box to be output under edge-control. This is most easily achieved with an R_TRIG or F_TRIG function block placed in series (see also examples below).
Using the ADSLOGDINT function a DINT value (4 byte signed integer) can be inserted in the text to be output at a point specified by the user. For this purpose, the stored format string must contain the characters ‘%d’ at the desired location. The result value contains the function error code, or, if successful, 0.
FUNCTION ADSLOGDINT : DINT
VAR_INPUT
msgCtrlMask : DWORD;
msgFmtStr : T_MaxString;
dintArg : DINT;
END_VAR
msgCtrlMask : Control mask which determines the type and effect of the message output (see separate table).
Constant | Description |
---|---|
ADSLOG_MSGTYPE_HINT | Message type is advice. |
ADSLOG_MSGTYPE_WARN | Message type is warning. |
ADSLOG_MSGTYPE_ERROR | Message type is error. |
ADSLOG_MSGTYPE_LOG | Message is written into the log. |
ADSLOG_MSGTYPE_MSGBOX | Message is output to a message box. |
ADSLOG_MSGTYPE_RESOURCE | Message is fetched from a resource file. (not currently supported) |
ADSLOG_MSGTYPE_STRING | Message is a directly given string (default). |
The control masks can be ORed in the desired combination.
msgFmtStr : Contains the message to be issued. It can contain the formatting code ‘%d’ for the output of a DINT value at any position.
dintArg : Contains the numerical value to be inserted into the message.
Example of calling the function in FBD:

The resulting message box
The DINT value 4711 is inserted here into a message. The insertion point is marked by the %d characters in the format string.
Example of calling the function in ST:
rtMessageOutput: R_TRIG; (* Declaration*)
bFeedTooHigh: BOOL;
udiAdsLogRes: UDINT;
(*--------------------------------------*)
rtMessageOutput(CLK := bFeedTooHigh);
IF rtMessageOutput.Q THEN
UdiAdsLogRes := ADSLOGDINT( msgCtrlMask :=
ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_MSGBOX,
msgFmtStr := 'PLC
Msg: Feed too high! Current feed: %d',
dintArg:= 4711);
END_IF;
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | PLCSystem.Lib |
TwinCAT v2.8.0 | PC or CX (x86) | TcSystem.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) | TcSystem.Lib |