XPost: comp.lang.pascal.misc   
   From: me7@privacy.net   
      
   On Fri, 20 May 2005 08:47:48 +0000 (UTC), in   
   , Marco van de Voort   
    wrote:   
      
   >On 2005-05-20, Claudio Cauchi wrote:   
   >> I solved the problem by eliminating the call to randomize; in the   
   >> procedure generateStudent(var stu:student_record); I still can't   
   >> explain why this happens! It seems that randomize was actually slowing   
   >> down something that wouldn't let the var parameter get updated..Boh   
   >   
   >Nope, since none of these commands are asynchronous. This is not a scripting   
   >language, everything is processed in order. You really should check your own   
   >code for flaws.   
      
   Of course it's the code, but he can't spot this particular code   
   flaw unless he knows the internal workings of the compiler.   
      
   The problem is that he placed his call to randomize within the   
   generateStudent procedure which is within for..loop so he's   
   reseeding his RNG each time thru the loop. A fast machine could   
   easily make the required 10 passes thru the loop before the   
   system clock ticks over to the next value. Since randomize seeds   
   the random number generator from the system clock all his random   
   data could be identical, or at most two sets of data since even a   
   slow machine will probably run the code before the clock ticks   
   twice.   
      
   Removing randomize from the generateStudent procedure and placing   
   it before the for..loop should solve the problem and allow   
   removal of the delay.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|