- Overview
- 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. Displaying information 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. 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:
PROCÉDURE MyTrace(StringToTrace) IF InTestMode() = True THEN Trace(StringToTrace) END
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).
PROCÉDURE MyTrace(StringToTrace) FilePath is string FilePath = fDataDirUser() + ProjectInfo(piProjectName) + ".txt" FileNum is int DebugMode is boolean = False IF Position(CommandLine(), "/DEBUG") > 0 THEN DebugMode = True END IF DebugMode = True THEN Trace(StringToTrace) ELSE 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, StringToTrace) fWriteLine(FileNum, " ") fClose(FileNum) END END
Remarks: - 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…
|
|
|
|