|
Assert Function Delphi
|
|
07-29-2010, 01:09 AM
Post: #1
|
|||
|
|||
|
Assert Function Delphi
This function is a bit advanced. It is used when you are testing/debugging your program in Delphi.Assert function is a debugging tool for testing if a certain conditions are always True. Assert tests whether a Boolean expression expr is true. If not, Assert raises an EAssertionFailed exception. If a message string was passed to Assert, the exception object is created with that string (Exception.CreateFmt).
Assert provides an opportunity to intercept an unexpected condition and halt a program rather than allow execution to continue under unanticipated conditions. Syntax is like this : Code: function Assert(Condition:Boolean; [Message:String]);In the procedure of the button put this piece of code : Code: procedure TForm1.Button1Click(Sender: TObject);You will get a dialog like this : ![]() That is because k is bigger than 5, k is 10. And if condition is okay, program will continue as nothing happened. You can use this for many tests ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
07-29-2010, 02:08 AM
Post: #2
|
|||
|
|||
|
RE: Assert Function Delphi
Nice post... this can come really handy in testing and debugging program!
Read rules ![]()
|
|||
|
07-29-2010, 05:45 AM
Post: #3
|
|||
|
|||
|
RE: Assert Function Delphi
Kind of like assert in C
Thanks for the share
"Character is determined more by the lack of certain experiences than by those one has had." Friedrich Nietzsche |
|||
|
« Next Oldest | Next Newest »
|



![[Image: 71827_assertfunction.jpg]](http://myph.us/pics/71827_assertfunction.jpg)




Thanks for the share