WEBDEV Concepts
Part 6: Testing aWeb site 199 5.4 Debugging without debugger In some cases, running a program with or without debugger may be different. The debugger sets pauses in the execution of the processes, during which Windows performs multiple tasks. Therefore, the debugger cannot be used in a procedure called by a timer or in the code of a scrollbar. Remark : For more details on the limitation of the debugger, see the online help. To debug these applications, you may want to follow the changes of a value, how different procedures are called, etc. 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. Displaying information Two tools can be used to display information: • information boxes : WLanguage Info function. Caution: When displayed, dialog boxes block the application. • the trace window : WLanguage Trace function. The trace window appears in the upper-left corner of the screen, without interrupting the program. Displaying the 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: PROCEDURE MyTrace(StringToTrace) IF InTestMode() THEN Trace(StringToTrace) END In this code, depending on the result of InTestMode , the trace window appears during the application test only. This procedure prevents trace windows from being displayed on end-user computers, even if they are called in the code of the application. 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 processing, etc.), to check the operating mode of the program, you must keep a physical trace of the processes run (a text file, for example). The following procedure allows you to define how the trace will be displayed: • on the screen (/DEBUG parameter in command line). • in a text file (default mode). PROCEDURE MyTrace(StringToTrace) FilePath is int FilePath = fDataDirUser() + ... ProjectInfo(piProjectName) + ".txt" FileNum is int DebugMode is boolean = False IF Position(CommandLine(), "/DEBUG") > 0 THEN DebugMode = True END IF DebugMode THEN Trace(StringToTrace) ELSE FileNum = fOpen(FilePath, ... foCreateIfNotExist + ... foWrite + foAdd) If FileNum <> -1 THEN DateTimeTrace is DateTime DateTimeTrace = SysDateTime() DateTrace is Date DateTrace = DateTimeTrace.Date TimeTrace is Time TimeTrace = DateTimeTrace.Time fWriteLine(FileNum, ... DateToString(DateTrace) + ... " - " + TimeToString(TimeTrace)) fWriteLine(FileNum, ... StringToTrace) fWriteLine(FileNum, " ") fClose(FileNum) END END
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==