Delphi Hint Error line number assert (assert)

Source: Internet
Author: User

One, usage: Assert (expression)
1. If False assert generates a eassertionfailed exception, it is displayed as assertion Failed (C:/src/unit1.pas, [Size=+0]line 34)
2. If you no longer want to use these checks, you can use ($ASSERTIONS OFF) or ($C-) Compile instructions
3. To invalidate the assert for the entire project, close the project Options | Compiler | Assertion option.

II, Delphi Assert () function usage
assert (Assert) is used for conditional testing. Expression expressions can be evaluated, and if the value is False (that is, 0), then it prints an error message to stderr and then terminates the program by calling abort.

Iii. Usage Summary and precautions:
1) Verify the legitimacy of the incoming parameters at the beginning of the function
3) You cannot use a statement that alters the environment, because assert only takes effect in debug, and if you do, you will use the program to run into problems when it is actually running.
4) Assert and subsequent statements should be empty lines to create a logical and visual sense of consistency

Iv. Examples of programs
Procedure Tform1.button1click (Sender:tobject);
Begin
Parameter 1 is false when prompted, parameter 2 is the prompt character
Assert (False, ' This place is wrong! ‘);
End

Delphi Hint Error line number assert (assert)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.