PrintMessage
Function A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. - Generates a log message with any wanted strings in the Log Messages window.
Inputs
Input |
Data Type |
Range |
Unit |
Default |
Description |
---|---|---|---|---|---|
Level |
DINT |
0, 4 |
N/A |
No default |
Level of the logged message (i.e., it's importance).
The Range defines are:
|
Message |
STRING |
1 - 255 |
|
|
Content of the message. The string is a maximum of 255 characters. |
Outputs
Output |
Data Type |
Range |
Unit |
Description |
---|---|---|---|---|
Default (.Q) |
BOOL |
|
N/A |
Returns TRUE when the function successfully executes. See Pipe Network - General Rules for more information. |
Remarks
Source
PrintMessage uses the SYSTEM message type.
To view all messages generated by PrintMessage, go to the log configuration and select the specified level for the SYSTEM source.
Level
The message could be sent with a logging level from 0 to 4 that qualifies its importance.
- The highest level, 4, logs critical messages.
- Available levels are: Debug, Informational, Warning, Error, and Critical.
- Only Error and Critical messages a generated by default.
- To force the system to generate every message level, use the Configuration Settings to change the settings to the desired level.
-
-
Enabling all messages can slow down the application's execution.
To avoid locking up communications between the IDE "Integrated development environment" An integrated development environment is a type of computer software that assists computer programmers in developing software. IDEs normally consist of a source code editor, a compiler and/or interpreter, build-automation tools, and a debugger and Runtime In computer science, runtime (or run-time) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). Within KAS, runtime also refers to the virtual machine that manage the program written in a computer language while it is running, you must never include a print statement in your program that prints to the log every update cycle.
Usage
PrintMessage( LEVEL_DEBUG, 'Message string to be logged' );
FBD Language Example
FFLD Language Example
IL Language Example
Not available.
ST Language Example
// It's possible to create a temporary variable with the message.
MESSAGE := CONCAT( 'MachineState=', ANY_TO_STRING(MachineState), '. MachineSpeed=', ANY_TO_STRING(MachineSpeed) );
// Then print the message to the log window
PrintMessage( LEVEL_INFO, MESSAGE );
PrintMessage( LEVEL_WARNING, MESSAGE );
PrintMessage( LEVEL_ERROR, MESSAGE );
// Or to create the string directly in the function call:
PrintMessage( LEVEL_CRITICAL, CONCAT( 'MachineState=', ANY_TO_STRING(MachineState), '. MachineSpeed=', ANY_TO_STRING(MachineSpeed) ) );