Defines the start of some controlled action
  1. for   Variable := Expression to Expression do Statement;
  2. while Expression do Statement
  3. try   Statements except on ExceptionClass do Statement; end;
  4. with  Expression do Statement
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
 Author links

 Download this web site as a Windows program.

Example code : Show singles and block do statement blocks
  i : Integer;

  // A for statement - the do keyword precedes a single statement
  for i := 1 to 3 Do
    ShowMessage('For loop, i = '+IntToStr(i));

  // A while statement - the do precedes a statement block
  while i < 6 Do
    ShowMessage('While loop, i = '+IntToStr(i));
Show full unit code
   For loop, i = 1
   For loop, i = 2
   For loop, i = 3
   While loop, i = 4
   While loop, i = 5
'); document.write('
'); document.write('
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page