var iNumber : Integer;
begin
//some value must be
//assigned to iNumber here!
if iNumber = 0 then
ShowMessage('Zero value encountered!');
end;
var iNumber : Integer;
begin
//some value must be
//assigned to iNumber here!
if iNumber = 0 then
begin
ShowMessage('Zero value encountered!');
Exit; // exit from the current procedure
end;
//if iNumber is 0 the folowing
//code will never be executed
ShowMessage('Nobody likes 0, ha!');
end;
var iNumber : Integer;
begin
//some value must be
//assigned to iNumber here!
if iNumber < 0 then
begin
//statements ...
ShowMessage('Your number is negative!');
//statements ...
end
else
begin
//statements ...
ShowMessage('Your number is positive or zero!');
//statements ...
end;
end;
var iNumber : Integer;
begin
if iNumber = 0 then
begin
ShowMessage('Zero number not allowed!');
exit;
end
else
//no need to use begin-end here
if iNumber < 0 then
ShowMessage('Your number is negative!')
else
ShowMessage('Your number is positive!');
end;
var iNumber : Integer;
begin
//some value must be
//assigned to iNumber here!
begin
case iNumber of
0:
ShowMessage('Zero value');
1..10 :
ShowMessage('Less than 11, greater than 0');
-1, -2, -3 :
ShowMessage('Number is -1 or -2 or -3');
else
ShowMessage('I do not care');
end;
end;