Increment an ordinal variable System unit
1  procedure Inc ( var Variable : Ordinal variable ) ;
2  procedure Inc ( var Variable : Ordinal variable; Count : Integer ) ;
The Inc procedure increments the ordinal Variable parameter passed to it.
You can increment :
Non-floating number types 
Enumeration types 

The increment is by the base size of the unit. For example, incrementing a Pointer will be by 2 bytes if the pointer points to Words.
Version 1 of Inc increments by 1 unit.
Version 2 of Inc increments by Count units.
Inc is equivalent in performance to simple addition, or the Succ procedure.

Count can be negative.
Related commands
Dec Decrement an ordinal variable
Pred Decrement an ordinal variable
Sqr Gives the square of a number
Sqrt Gives the square root of a number
Succ Increment an ordinal variable
Sum Return the sum of an array of floating point values
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Incrementing characters, numbers and enumerations
  TSuit = (Hearts, Clubs, Diamonds, Spades);
  Character : char;
  Number    : Integer;
  Card      : TSuit;

  // We can increment characters
  Character := 'A';

  ShowMessage('Character : '+Character);
  ShowMessage('Character+1 : '+Character);

  // We can increment numbers
  Number := 23;

  ShowMessage('Number : '+IntToStr(Number));
  Inc(Number, 5);
  ShowMessage('Number+5 : '+IntToStr(Number));

  // We can increment enumerations
  Card := Clubs;

  ShowMessage('Card starts at Clubs');
  if Card = Hearts then ShowMessage('Card is now Hearts');
  if Card = Clubs then ShowMessage('Card is now Clubs');
  if Card = Diamonds then ShowMessage('Card is now Diamonds');
  if Card = Spades then ShowMessage('Card is now Spades');
Show full unit code
   Character : A
   Character+1 : B
   Number : 23
   Number+5 : 28
   Card starts at Clubs
   Card is now Diamonds
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page