| View previous topic :: View next topic |
| Author |
Message |
Velocity Guest
|
Posted: Wed May 02, 2007 2:26 pm Post subject: FileInstall lets Random generate always the same number |
|
|
When I was writing a script I stumbled on a strange bug in AHK:
If FileInstall is executed before Random, always the same number is generated. This happens only, when FileInstall is actually executed. So it happens only in compiled scripts and only, when the file to install already exists and the flag isn't set.
Try to compile and run this script:
| Code: | FileInstall, Test.txt, %A_WorkingDir%\datei.txt, 1
Loop, 10
{
Random, Var, 1, 25
MsgBox, %Var%
} |
Now remove FileInstall and try it again. You see now Random works properly! This problem is confirmed by a user of the german forum.
Velocity |
|
| Back to top |
|
 |
Helpy Guest
|
Posted: Wed May 02, 2007 2:40 pm Post subject: |
|
|
I didn't tried your test script, but it is strange indeed. From the Random page, the seed is based only on the computer's timer.
Did you tried some other seed?
BTW, you should mention the AutoHotkey version and the system version, in case they are relevant. |
|
| Back to top |
|
 |
Velocity Guest
|
Posted: Wed May 02, 2007 3:15 pm Post subject: |
|
|
I have installed the newest AHK version 1.0.46.14 and my OS is WindowsXP Home.
With a new seed I get another number, but that is always the same as well! |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed May 02, 2007 4:55 pm Post subject: |
|
|
Since I see no explanation for it in the code, the problem may lie in the part of the ahk2exe source code I don't have access to.
In any case, it will be fixed in the next update by reseeding the random number generator after each FileInstall. This new code will execute only in compiled scripts because (as you pointed out) the problem doesn't affect .ahk scripts.
Thanks. |
|
| Back to top |
|
 |
Velocity Guest
|
Posted: Wed May 02, 2007 7:11 pm Post subject: |
|
|
Thanks a lot for the reply Chris.
But one last question. Why don't you have access to the ahk2exe code? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed May 02, 2007 7:27 pm Post subject: |
|
|
| To my knowledge, the code that stores and extracts files from inside compiled scripts hasn't been released by its author, Jonathan Bennett. So the program is built using a .LIB file that contains the necessary functions. |
|
| Back to top |
|
 |
|