From Delphi Help:
function Random [ ( Range: Integer) ];
Description
In Delphi code, Random returns a random number within the range 0 <= X < Range. If Range is not specified, the result is a real-type random number within the range
0 <= X < 1.
To initialize the random number generator, add a single call Randomize or assign a value to the RandSeed variable before making any calls to Random.
So the random number returned from Random(1) is always 0.
Change to
[pascal]
RandomNumber := Trunc(Random * 2)+1;
[/pascal]
To get a 1 or 2 result.
Random * 2 - will return a number between 0 and 1.999999.
Trunc drops the digits after the '.' - So a number betwenn 0 and 1
[size=7px]Does anyone ealse feel we are doing someones homework....[/size]
Bookmarks