Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use Random method in Console Application in Delphi 7

Tags:

random

delphi

Is it not possible to use Random method in Console Application in Delphi? It won't compile and shows the error:

'.' expected but '(' found

When I try to do the same thing in normal application (with windows), it works.

The whole code I'm trying to compile is here:

program random;

{$APPTYPE CONSOLE}

uses SysUtils;

var iRan:integer;

begin
  Randomize;
  iRan:=Random(10);
  writeln(iRan);
  readln;
end.
like image 286
daralim Avatar asked Jan 20 '17 21:01

daralim


1 Answers

Your program is named random. That name hides that name in System.

Either use a different program name or fully qualify the function, System.Random.

like image 200
David Heffernan Avatar answered Oct 11 '22 14:10

David Heffernan