PrintMessage

PLCopen motion icon Pipe Network motion icon

 FunctionClosed 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. - used to generate a log message with any wanted strings in the Log Messages window.

Input

Level Description Level of the logged message. In other words, its importance. Keep in mind that not all messages are displayed in the log windows by default. Only Error and Critical messages are displayed by default. Change the log settings to display a lower level. PrintMessage logs SYSTEM messages.
  Data type DINT
  Range

[0 , 4]

Defines are: LEVEL_DEBUG, LEVEL_INFO, LEVEL_WARNING, LEVEL_ERROR, LEVEL_CRITICAL

  Unit N/A
  Default
Message Description Content of the message. A string of 255 characters maximum.
  Data type String
  Range 1 to 255 characters
  Unit N/A
  Default

Output

Default (.Q) Description

Returns true when function successfully executes.

See Function - General Rules for more information.
  Data type BOOL
  Unit N/A

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.

Usage

PrintMessage(  LEVEL_DEBUG, 'Message string to be logged' );

Structured Text

            // 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) ) );

 

FBD Language

PrintMessage: FBD example

FFLD Language