he “case(i: var)” operator provides a structured equivalent to a sequence of “if” statements for the same variable.
The “case” statement is more elegant, more efficient, and easier to maintain than multiple “if” conditions.
For i:=1 to 2 do
begin
case (i) of // sellected value according to the variable “i”
1: ShowMessage (‘The first condition has occured’);
2: ShowMessage (‘The first condition has occured’);
else ShowMessage (‘Nothing happened’);
end;
end;
Also it is possible to use default setting for the case structure:
default: ShowMessage (‘Default settings are applied’);