I didn't know what to put in the title sorry..
What I have is a random number ( used for a random time of pause) generated using Random.. which works great .
Random, RandPause30to60, 30000, 60000
Sleep, %RandPause30to60%
I'm trying to pair down the code as I find myself having to Run the Random generator each time I use a pause, otherwise the variable is not populated with a newly randomized number.
Is there a way of making a function or something that when used triggers the Random and passes that to a varible anywhere in the code, or do I just have to repeat the Random code every-time I need a new number ?
Although its not a huge problem as I expect if I created a function I would still have to paste the function code in, was just curious if anyone had a niffty way of .. like I said "shrinking" the code for this type of problem.
Thanks
Random and functions ?
Re: Random and functions ?
Code: Select all
Sleep % Rand(30,60)
SoundBeep
Sleep % Rand(15,30)
SoundBeep
Sleep % Rand(0.5,2)
SoundBeep
MsgBox % Rand(200,300)
F12::MouseMove, Rand(0,A_ScreenWidth), Rand(0,A_ScreenHeight)
Rand(min,max) {
Random, res, min, max
Return res * 1000
}
Re: Random and functions ?
Thanks I'll try this outBoBo wrote:Not tested.Code: Select all
Sleep % Rand(30,60) SoundBeep Sleep % Rand(15,30) SoundBeep Sleep % Rand(0.5,2) SoundBeep MsgBox % Rand(200,300) F12::MouseMove, Rand(0,A_ScreenWidth), Rand(0,A_ScreenHeight) Rand(min,max) { Random, res, min, max Return res * 1000 }
Who is online
Users browsing this forum: Bing [Bot], Marium0505, mcl and 339 guests