downto
The DownTo keyword prefixes the target value Expression in a For loop. The DownTo
expression maybe an Integer, Character or Enumeration type.
For more details, see the keyword for. The example illustrate the three expression types.
Example
Download This Source for Free Pascal
var
i : Integer;
c : char;
suit : (Hearts, Clubs, Diamonds, Spades);
begin
// Loop 5 times
for i := (10 div 2) DownTo 1 do Writeln('i = ',i);
// Loop 5 times
for c := 'E' DownTo 'A' do Writeln('c = ',c);
// Loop 3 times
for suit := Diamonds DownTo Hearts do
Writeln('Suit = ',Ord(suit));
end.
Output
i = 5
i = 4
i = 3
i = 2
i = 1
c = E
c = D
c = C
c = B
c = A
Suit = 2
Suit = 1
Suit = 0
See Also
Begin,
End,
For,
To.