AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FileInstall lets Random generate always the same number

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Velocity
Guest





PostPosted: Wed May 02, 2007 2:26 pm    Post subject: FileInstall lets Random generate always the same number Reply with quote

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





PostPosted: Wed May 02, 2007 2:40 pm    Post subject: Reply with quote

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





PostPosted: Wed May 02, 2007 3:15 pm    Post subject: Reply with quote

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

PostPosted: Wed May 02, 2007 4:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Velocity
Guest





PostPosted: Wed May 02, 2007 7:11 pm    Post subject: Reply with quote

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

PostPosted: Wed May 02, 2007 7:27 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group