SystemPred (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example demonstrates how Pred and Succ can be used to manage enumerations.

Code

procedure TForm1.Button1Click(Sender: TObject);
type
  Colors = (RED,BLUE,GREEN);
var
  S: string;
begin
  S := 'The predecessor of 5 is ' + IntToStr(Pred(5)) + #13#10;
  S := S + 'The successor of 10 is ' + IntToStr(Succ(10)) + #13#10;
  if Succ(RED) = BLUE then
    S := S + 'In the type Colors, RED is the predecessor of BLUE.';
  MessageDlg(S, mtInformation, [mbOk], 0, mbOk);
end;

Uses

Personal tools
Assistance