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. Please keep in mind that the function must be called edge-triggered (see also note in description ADSLOGDINT). The return parameter contains the function error code, or 0 if successful.
FUNCTION ADSLOGSTR : DINT
Inputs
VAR_INPUT
msgCtrlMask : DWORD;
msgFmtStr : T_MaxString;
strArg : T_MaxString;
END_VAR
Name | Type | Description |
---|---|---|
msgCtrlMask | DWORD | Control mask which determines the type and effect of the message output (see separate table). |
msgFmtStr | Contains the message to be output. It can contain the formatting character %s for the output of a text argument at any position. Information: The length of the message is limited to 253 bytes (corresponds to 253 characters for strings in standard format). | |
strArg | Contains the string which is to be inserted into the message. |
Constant | Description |
---|---|
ADSLOG_MSGTYPE_HINT | Message type is hint. |
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 in a message box. |
ADSLOG_MSGTYPE_STRING | Message is a directly given string (default). |
The control masks can be ORed in the desired combination.
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:
PROGRAM MAIN
VAR
strSFCErrorStep : STRING; (* Declaration*)
rtMessageOutput: R_TRIG;
bSFCError: BOOL;
END_VAR
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;
Prerequisites
Development Environment | Target platform | PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, Arm®) | Tc2_System (system) |