I am currently using the CRT to allow for a delay to create a multitude of random numbers without having a bunch of numbers be the same (<- im terrible with grammar). so i used a writeln to see the numbers my script was generating and it wouldnt allow me to see all the numbers.
For x := 1 to 100 Do
With people[x] Do
Begin
randomize;
people[x].Address:='4562 South abigail lane';
people[x].Phonenum:='555-555-1234';
people[x].licence:='ABC3456789';
people[x].tickets:=random(5);
People[x].age:=16+random(10000) mod 80 + 1;
delay(50);
writeln(people[x].age);
End;
so as you can tell it makes a little issue with checking the numbers. so if possible could someone provide me with an alternative?
i used a writeln to see the numbers my script was generating and it wouldnt allow me to see all the numbers.
One thing you could do is to add a line
readln;
after your for
loop. That way, you will need to press any key when your app reaches that line. You should then find that you don't need the delay(50);
line at all.
Two other things:
1) Move call to Randomize
outside the loop. It should be called exactly once, at the start of your program. The FreePascal documentation does not specify this, but it demonstrates it in the example of using Random. The Delphi RTL documentation makes this much clearer:
Do not combine the call to Randomize in a loop with calls to the Random function. Typically, Randomize is called only once, before all calls to Random.
2) (Combined in the code below), get out of the habit of using with
, ever. The time is saves in typing by using it is trivial compared with the time you may end up spending trying to track down obscure errors that are caused by using it.
Randomize;
for x := 1 to 100 do
begin
people[x].Address := '4562 South abigail lane';
people[x].Phonenum := '555-555-1234';
people[x].licence := 'ABC3456789';
people[x].tickets := random(5);
people[x].age := 16 + random(10000) mod 80 + 1;
//delay(50); pointless
writeln(people[x].age);
end;
readln;