Ploxc

WinCC Unified Debug Proxy
Guides

Debugging Tips

Use the debugger statement

For scripts that run automatically (like onLoad on faceplates), place a debugger statement in your code to pause execution at that point:

debugger;
// your code here

This works like a breakpoint, but is defined in the script itself.

Tip: use an HMI tag to toggle the debugger

To avoid having to remove debugger statements every time you're done debugging, use a global HMI tag as a switch:

if (HMIRuntime.Tags("DebugMode").Read()) debugger;

Create a DebugMode tag (Boolean) in your project. Set it to true when you want to debug, false when you don't. This way you can leave the debugger statements in your code.

Debugging events vs. lifecycle scripts

Events (like button clicks) are the easiest to debug — start your debug session, then trigger the event by clicking the button. The debugger will hit your breakpoints reliably.

Lifecycle scripts (like onLoad) are trickier because they run immediately when a screen opens. The debugger may not be attached in time to catch them.

Tip: use openScreenInPopup for onLoad debugging

To reliably debug an onLoad script:

  1. Start the debug session on a screen that does not contain the faceplate you want to debug
  2. Add a debugger statement in the onLoad script
  3. From the current screen, call openScreenInPopup to open the screen with your faceplate
  4. The debugger is already attached, so it will pause on the debugger statement

This way the debug session is running before the faceplate loads.

Pause on exceptions

Enable Pause on caught exceptions and Pause on uncaught exceptions in VS Code's debugger. This makes the debugger stop on any error in your scripts, so you can catch issues immediately without needing breakpoints everywhere.

You can find these options in the Breakpoints section of the Run and Debug panel.