ADSLOGSTR

ADSLOGSTR 1:

This function issues when called a message box holding a specifiable text on the screen, and writes an entry into the system's log. In the text to be given out, a string (a sequence of characters) can be inserted in the text at a point specified by the user. For this purpose the stored format must contain the characters %s at the desired location. Always remember that here too, as illustrated in the example, the function must be called using edge-control (see also the note in the description of ADSLOGDINT). The result value contains the function error code, or, if successful, 0.

FUNCTION ADSLOGSTR : DINT

ADSLOGSTR 2: 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 at ADSLOGDINT).

msgFmtStr

T_MaxString

Contains the message to be issued (type: T_MaxString). It can contain the formatting code %s for the output of a text argument at any position.

strArg

T_MaxString

Contains the string to be inserted in the message (type: T_MaxString).

Example of calling the function in FBD:

ADSLOGSTR 3:

The resulting message box:

ADSLOGSTR 4:

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;

Requirements

Development environment

Target system type

PLC libraries to include (Category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_System (System)