| Description |
|
The Do keyword is always a part of one of the shown 4 control types. It precedes the Statements section of the control action.
|
|
| Related commands |
| Begin |
|
Keyword that starts a statement block |
| End |
|
Keyword that terminates statement blocks |
| Except |
|
Starts the error trapping clause of a Try statement |
| For |
|
Starts a loop that executes a finite number of times |
| Repeat |
|
Repeat statements until a ternmination condition is met |
| Try |
|
Starts code that has error trapping |
| While |
|
Repeat statements whilst a continuation condition is met |
| With |
|
A means of simplifying references to structured variables |
|
|
|
| Example code : Show singles and block do statement blocks |
var
i : Integer;
begin // A for statement - the do keyword precedes a single statement
for i := 1 to 3 Do
WriteLn('For loop, i = '+IntToStr(i));
// A while statement - the do precedes a statement block
while i < 6 Do
begin
WriteLn('While loop, i = '+IntToStr(i));
Inc(i);
end;
end;
|
| Show full unit code |
For loop, i = 1
For loop, i = 2
For loop, i = 3
While loop, i = 4
While loop, i = 5
|
|