F_BA_LogMessage2

F_BA_LogMessage2 1:

This function works like F_BA_LogMessage1, but two message texts tArg1 and tArg2 can be added at the end.

Following the sample program from F_BA_LogMessage1, a second "%s" must be added to the end of the message to display the additional message.

Sample

F_BA_LogMessage2 2:

There are eight more blocks of the same type: F_BA_LogMessage3 to F_BA_LogMessage10. With these functions it is possible to add three to ten additional messages. For each message, another text variable must then be created, sText3 to sText10 and a "%s" must be added to the message in line two of the above sample in each case.

Output

F_BA_LogMessage2 3:

The generated code is used to identify a specific location in the source code. The sample shown above serves to illustrate how this function works. Basically, a distinctive abbreviation (e.g. "IO50" if a message is issued within the method InitObject in line 50) should be explicitly specified for the generation of the log messages.

This will display an error at runtime and the shortcut "Ctrl+F" will reach the erroneous location.

Syntax

FUNCTION F_BA_LogMessage
VAR_INPUT
  nLogType    : DWORD     := ADSLOG_MSGTYPE_ERROR;
  sLogCode    : STRING    := '';
  sLogText    : T_MaxString;
  tArg1       : T_Arg;
  tArg2       : T_Arg;
END_VAR

F_BA_LogMessage2 4: Inputs

Name

Type

Description

nLogType

DWORD

Log type, which can be set as a mask. The message is then output depending on the setting of this mask. The mask for ADSLOG_MSGTYPE_LOG is set internally as well.

sLogCode

STRING

An argument in textual form that precedes the message.

sLogText

T_MaxString

Message as text.

tArg1

T_Arg

Further message text, which is placed at the end.

tArg2

T_Arg

Further message text, which is placed at the end.

Requirements

Development environment

Required PLC library

TwinCAT 3.1 4024.35

Tc3_BA2_Common from V2.1.20.0