2
votes

I am trying to use the randomrange function in Delphi XE2 but for some reason it keeps giving me an undeclared identifier error when trying to run it, here is my code.

var
  Form3: TForm3;
  number_of_digits, values, single, doubledig, triple, four, I : nativeint;

implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);

begin
  Randomize;
  number_of_digits := radiogroup1.ItemIndex;
  single := RandomRange(0, 9);
  doubledig := RandomRange(10,99);
  triple := RandomRange(100,999);
  four := RandomRange(1000,9999);
  case number_of_digits of
  0 : values := single;
  1 : values := doubledig;
  2 : values := triple;
  3 : values := four;
  end;

The error I am getting is

E2003 Undeclared identifier: 'RandomRange'

Any help would be appreciated.. Thanks.

1

1 Answers

6
votes

The RandomRange function is in the Math unit. Add that unit to your uses clause.

uses
  System.Math;