ADSLOGSTR
When called, the function outputs a message box with a predefinable text to the screen and writes an entry to the system's event log. A string can be inserted into the text to be output at a position specified by the user. For this purpose, the created format string must contain the string '%s' at the desired position.
![]() | Here, as also shown in the sample, the function must be called using edge-control (see also description ADSLOGDINT). |
The return parameter contains the function error code, or 0 if successful.
FUNCTION ADSLOGSTR : DINT
VAR_INPUT
msgCtrlMask : DWORD;
msgFmtStr : T_MaxString;
strArg : T_MaxString;
END_VAR
msgCtrlMask : Control mask which determines the type and effect of the message output (see separate table: ADSLOGDINT).
msgFmtStr : Contains the message to be issued. It can contain the formatting code ‘%d’ for the output of a DINT value at any position.alten.
strArg : Contains the string which is to be inserted into the message.
Example of calling the function in FBD:

The resulting message box
With this, the PLC programmer inserts the string stored in the variable ‘strSFCErrorStep’ into the message. The insertion point is marked by the %s characters in the format string.
Example of calling the function in ST:
strSFCErrorStep : STRING; (* Declaration*)
rtMessageOutput: R_TRIG;
bSFCError: BOOL;
(*--------------------------------------*)
rtMessageOutput(CLK := bSFCError);
IF rtMessageOutput.Q THEN
udiAdsLogRes := ADSLOGSTR( msgCtrlMask :=
ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_MSGBOX,
msgFmtStr := 'PLC Msg.:
Guarding time executed in SFC step: %s', strArg :=
strSFCErrorStep);
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 |