Article number: KB000003
Related blocks:
The System system assembly has the Debug class that is used to display debug information when executing units or forms. This class has several static methods that are used to solve various tasks:
Write, WriteLine. They are used to display the specified string. By default, all debug messages are displayed in the Console Window panel of the development environment.
WriteIf, WriteLineIf. They are used to display the specified string only when the specified condition is satisfied.
Indent, Unindent. They are used to display the specified string with an indent with respect to previous strings.
The Assert method enables the user to insert a condition to the code for checking the state of executed code. If the code does not satisfy the specified condition, an appropriate message is displayed. Developers often write code for procedures and functions based on some assumptions on values of their parameters. This method enables the user to include checking these assumptions in the code and find problems at testing stage if these problems really exist.
The Fail method enable the user to report a serious problem that arises during code execution.
Developers often use the IWinApplicationClass.InformationBox function to display debug messages. Its use can lead to the malfunctioning of application system web version. It is recommended to take this into account when developing application systems.
Sub UserProc;
Var
Value: Double;
Begin
Debug.WriteLine("Hello, world!");
Value := Math.Rand;
Debug.Write("Random value: "); Debug.WriteLine(Value);
Debug.WriteLineIf(Value > 0.5, "Random value is greater than 0.5");
Debug.WriteLine("Indented random outputs");
Debug.Indent;
Try
Debug.WriteLine(Math.Rand);
Debug.WriteLine(Math.RandBetween(0, 100));
Finally
Debug.Unindent;
End Try;
Debug.Assert(Math.Rand > 0.5);
Debug.Fail("There is an serious failure in software");
End Sub UserProc;
The console window displays the following:
Unit execution is started
Hello, world!
Random value: 0,175467571750159
Indented random outputs
0,64320357647799
11,6849231109221
Assert failed
There is an serious failure in software
Unit execution finished
See also: