SmartPascal
Succ
Function
Increment an ordinal variable System unit
 function Succ ( const Ordinal Value ) : Ordinal type;
Description
The Succ function increments an ordinal value, and returns this value.
 
You can increment :
 
Characters 
Non-floating number types 
Enumeration types 
Pointers 

 
The increment is by the base size of the unit. For example, incrementing a Pointer will be by 4 bytes if the pointer points to Words.
 
Notes
Succ is equivalent in performance to simple addition, or the Inc procedure.
Related commands
Dec Decrement an ordinal variable
Inc Increment an ordinal variable
Pred Decrement an ordinal variable
Sqr Gives the square of a number
Sqrt Gives the square root of a number
Sum Return the sum of an array of floating point values
 
Example code : Incrementing characters, numbers and enumerations
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

type
  TSuit = (Hearts, Clubs, Diamonds, Spades);

var
  Character : char;
  Number    : Integer;
  Card      : TSuit;

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

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

  // We can increment numbers
  Number := 23;

  ShowMessage('Number : '+IntToStr(Number));
  Number := Succ(Number);
  ShowMessage('Number+1 : '+IntToStr(Number));

  // We can increment enumerations
  Card := Clubs;

  ShowMessage('Card starts at Clubs');
  Card := Succ(Card);
  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');
end;
 
end.
Hide full unit code
   Character : A
   Character+1 : B
   Number : 23
   Number+1 : 24
   Card starts at Clubs
   Card is now Diamonds