Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
function AssertAssert(expr : Boolean [; const msg: string]);
Use Assert as a debugging tool to test that certain conditions are always True (as assumed).
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.
{
A simple function that accepts a
string and a delimiter char, splits a
string into tokens (TStringList items)
delimited with a char value.
Usage:
procedure TForm1.Button1Click(Sender: TObject);
var
A: TStringList;
begin
A := TStringList.Create;
try
Split(' ', 'your delphi guide', A);
ShowMessage(a[0]); //your
ShowMessage(a[1]); //delphi
ShowMessage(a[2]); //guide
finally
A.Free;
end;
end;
}
procedure Split
(const Delimiter: Char;
Input: string;
const Strings: TStrings);
begin
Assert(Assigned(Strings));
Strings.Clear;
Strings.Delimiter := Delimiter;
Strings.DelimitedText := Input;
end;
|
Before you start optimizing Delphi code
How to make sure that the Murphy's law: "Any program will expand to fill available memory" does not apply to your Delphi applications.
Since assertions are not usually used in final product version, Delphi compiler includes directives to disable the generation of assertion code:
$ASSERTIONS ON/OFF (long form)
Assigned,
|
Free Delphi code snippet inside every Delphi Newsletter! |
|
|
|
Got some code to share? Got a question? Need some help? |
|
|