DebugFN()

Evaluates any number of control expressions, if a specific debug flag is set and writes the result to stderr, followed by a new line.

Synopsis

int DebugFN(int|string dbgFlag,expression[, expression[, ...]]);

Parameters

Parameter Meaning
dbgFlag Debug flag that must be set in order that an output will be executed.
expression Control function to be evaluated.

Return Value

In the event of an error -1, otherwise 0.

Errors

Missing arguments.

Description

Any number of Control expressions can be evaluated with the DebugFN() function as with Debug(). The output is executed only then, if the entered debug flag is activated/set. You can activate a debug flag by entering the -dbg someFlagNameIInvent command on the command line when you start up the manager. The result is output to the terminal from which the calling UI manager or Control manager was started. Any number of arguments, separated by commas, can be processed, with each argument being output between square brackets '[ ]'. In contrast to Debug(), the function sets a new line after output of all the arguments.

You can suppress "DebugFN()" entries that are still found in the scripts for the appropriate Manager with an entry "ignoreDebug = 1"; in the config file under [general], [ctrl], [ui] or [event]. If no entry is added to the config file, the DebugFN()s are still output.

The _LINE_ constant can be used for outputting the current line number of the script. This constant is replaced by an integer constant in each script that contains the value of the current line number (e.g. DebugN("Line:", __LINE__);).

The format in which the DebugFN()s are output may vary for different WinCC OA versions. The function is used for troubleshooting in Control scripts!

Example

main()
{
  /*Note: to view all debug messages displayed here, you should
  enable
  the debug flags by adding: "-dbg level1,level2,6" to the
  control manager running this script.*/
  /*The following line will display text if the debug flag -dbg
  level1 is
  added to the control manager.*/
  DebugFN("level1", "Custom debug Level 1 is activated.");
  /*The following line will display text if the debug flag -dbg
  level2 is
  added to the control manager.*/
  DebugFN("level2", "Custom debug Level 2 is activated.");
  /*The following line will display text if the debug flag -dbg 6
  is
  added to the control manager.*/
  DebugFN(6, "Custom level 6 is enabled", __LINE__);
  //You can display all the expressions that Debug can:
  dyn_int dnValues = makeDynInt (1, 4, 22, 91);
  DebugFN("level1", "here is an array", dnValues);
  //The debug flags are not case sensitive.
  DebugFN("LevEL1", "Hello");
}

Assignment

Miscellaneous functions

Availability

UI, CTRL