- How to?
- Displaying information
- Managing the display of debug information
- Creating a trace file
Debugging without debugger
In some cases, running a program or a site with or without the debugger can produce different results.
Indeed, the debugger introduces pauses in the execution of the process during which several tasks are performed by WINDEV.
Therefore, the debugger cannot be used in a procedure called by timer or in the code of a scrollbar.
To debug these applications, you may want to follow the changes of a value, how different procedures are called, etc.
This method also allows you to debug the browser code (entered in WLanguage).
This information can be:
- displayed on the screen,
- stored in a trace file.
Caution: If the information is displayed on the screen, it must be displayed during the application tests only.
Two tools can be used to display information:
- The information boxes: Info WLanguage function. Caution: Displaying an information box is a locking operation.
- The trace window: WLanguage Trace function.
The trace window appears in the upper-left corner of the screen, without interrupting the program. If can also be displayed it in the interface via the "Debugger trace" pane
The trace window displayed from a Browser code is different from the one displayed from a Server code. Two trace windows can be displayed at the same time. The information found in the "Browser" trace window is not displayed in the "Debugger trace" pane.
Managing the display of debug information
Displaying the debug information on the screen is useful in test mode only.
Any unsuitable display must be removed before distributing an application.
To avoid any oversight, it is recommended to manage how the debug information is displayed via a global procedure. For example:
IF InTestMode() = True THEN
In this code, depending on the result of InTestMode
, the trace window appears when testing the application or site
Such procedure allows you to leave the call to the trace windows in the application code without any risk of displaying it on the end-user computers.
The call to this trace procedure is identical to the use of Trace
MyTrace("Customer: " + Customer.CustomerNum)
Creating a trace file
During long processes (batch processes, ...), to check how the program is running, you must keep a physical trace of the processes performed (a text file for example).
The following procedure is used to manage the trace display:
- On the screen (/DEBUG parameter in command line).
- In a text file (default mode).
FilePath is string
FilePath = fDataDirUser() + ProjectInfo(piProjectName) + ".txt"
FileNum is int
DebugMode is boolean = False
IF Position(CommandLine(), "/DEBUG") > 0 THEN
DebugMode = True
IF DebugMode = True THEN
FileNum = fOpen(FilePath, foCreateIfNotExist + foWrite + foAdd)
IF FileNum <> -1 THEN
DateTimeTrace is DateTime = SysDateTime()
DateTrace is string = MyDate..Date
TimeTrace is Time = MyDate..Time
fWriteLine(FileNum, DateToString(DateTrace) + ...
" - " + TimeToString(TimeTrace))
fWriteLine(FileNum, " ")
- The trace file is created by default in the user data directory. This file is named like the project. This file contains the information to trace during the program execution. The information is completed by the date and time of each "Trace". This allows you to detect a potential problem during the process.
- Example of trace file content:
01/12/2001 - 10:53:25:20
Customer name: Martin
01/12/2001 - 10:53:25:26
Customer name: Mirva
This page is also available for…