DEV Community

zuUwn21
zuUwn21

Posted on

# πŸ› Uniface Debugging: The `debug` Statement Explained

πŸš€ What is the debug Statement?

As a Uniface developer, you're certainly familiar with the challenges of debugging complex applications. The debug statement is a powerful tool that helps you step through your components and identify issues systematically.

πŸ“‹ Basics

Syntax: debug
Return Values: None
Usage: Allowed in all Uniface component types

πŸ”§ How Does It Work?

The debug statement puts your component into debug mode:

πŸ–₯️ GUI Environment

  • Starts the Uniface Debugger
  • Enables entering debugging commands
  • Provides a complete graphical interface

πŸ’» Character Mode

  • Shows a debug command line at the bottom of the screen
  • Works in text-based environments as well

🎯 Practical Application

Standard Implementation

;Exec trigger
debug
edit
end ; end trigger
Enter fullscreen mode Exit fullscreen mode

πŸ“± Development vs. Production Environment

During development, it's common to place the debug statement in the Switch Keyboard trigger at the application level:

trigger keyboardSwitch 
if ($logical("SwitchKeyboard") = "debug")
 debug
endif
end
Enter fullscreen mode Exit fullscreen mode

⚠️ Important Note: The statement should be removed before production or embedded in a conditional instruction!

🏒 Server Debugging

🚫 Limitations

The debug statement is not implemented for the Uniface Server:

  • The Debugger is neither started nor stopped
  • Windows server processes cannot start windowing applications that need a desktop to run on

πŸ’‘ Solution for Server Debugging

  1. Start the Debugger before the server (manually or via Uniface Router)
  2. For remote debugging: Configure a unique TCP port for communication

πŸ”§ Enabling Debugging in Deployed Applications

For the rare case when you need to debug in a production application:

Step 1: Add ProcScript

trigger keyboardSwitch 
if ($logical("SwitchKeyboard") = "debug")
 debug
endif
end
Enter fullscreen mode Exit fullscreen mode

Step 2: Modify Assignment File

[LOGICALS]
SwitchKeyboard=debug
Enter fullscreen mode Exit fullscreen mode

Step 3: Activate Trigger

Press GOLD Y to start the debugger.

πŸ”„ Alternative: The /deb Switch

You can also use the /deb switch to start the application together with the Debugger. This is particularly useful for systematic debugging from the beginning.

πŸŽ‰ Conclusion

The debug statement is an indispensable tool for every Uniface developer. It enables you to:

  • βœ… Step through code line by line
  • βœ… Inspect variables at runtime
  • βœ… Use flexible debugging strategies
  • βœ… Debug both locally and remotely

πŸ’‘ Tip: Use conditional debug statements during development and remove them before production for optimal performance!

This article was created with AI assistance and is based on the official Uniface 10.4 documentation. Do you have questions or additional tips for Uniface debugging? Feel free to share them in the comments! πŸš€

Top comments (0)