In this article:

General Information

Description

Example

Debug Print

Article number: KB000003

General Information

Related blocks:

Description

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:

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.

Example

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(0100));
    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:

Developers Knowledge Base