0_00_0 Posted April 25, 2009 Share Posted April 25, 2009 Hello There! I'm basically trying to make a string of x random numbers from 0-9. For example: genCode(4) could generate 3942. The problem I'm having now is that it just adds them togeather. I'm looking for a concat, or sprintf equivalent in autoIT. func genCode($length) $code = String("") $tempRand=0 $count = 0 while $length > $count $tempRand=Random(0, 9) $code = String($code) + String($tempRand) $count = $count + 1 WEnd return $code EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted April 25, 2009 Developers Share Posted April 25, 2009 $code = $code & $tempRand -or- $code &= $tempRand SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted April 25, 2009 Share Posted April 25, 2009 Random(0, 9, 1)If this is set to 1 then an integer result will be returned. Default is a floating point number.... if you want 0-9 whole numbers8) Link to comment Share on other sites More sharing options...
0_00_0 Posted April 25, 2009 Author Share Posted April 25, 2009 ok thanks a bunch that worked. Aside from generating anywhere from (x-2)->(x) numbers, but this isn't a huge issue right now. Just another quick question, I didn't want to start a whole new topic on it. Whenever I add a background picture to my GUI it disables all my controls. Here is my GUI code: #include <GUIConstants.au3> #include <String.au3> $width = 250 $height = 225 $hGui = guicreate("Generator", $width, $height) guisetstate(@SW_SHOW) ;this line give mah GUI errorZ! guictrlcreatepic("bk.jpg", 0, 0, $width, $height) $hNum1 = guictrlcreateinput("0123", 15, 70, 35, 25) $hNum2 = guictrlcreateinput("012345", 55, 70, 45, 25) $hNum3 = guictrlcreateinput("01234", 105, 70, 40, 25) $hNum4 = guictrlcreateinput("012345", 150, 70, 45, 25) $hNum5 = guictrlcreateinput("0123", 200, 70, 35, 25) $hGenNum1 = guictrlcreateinput("0000", 15, 130, 35, 25) $hGenNum2 = guictrlcreateinput("000000", 55, 130, 45, 25) $hGenNum3 = guictrlcreateinput("00000", 105, 130, 40, 25) $hGenNum4 = guictrlcreateinput("000000", 150, 130, 45, 25) $hGenNum5 = guictrlcreateinput("0000", 200, 130, 35, 25) $genButton = GUICtrlCreateButton("GENERATE", ($width/2)-20, 160) while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then Exit endif wEnd Link to comment Share on other sites More sharing options...
Developers Jos Posted April 25, 2009 Developers Share Posted April 25, 2009 Move the Picture control to the end, its now on top of the other controls. $hNum1 = guictrlcreateinput("0123", 15, 70, 35, 25) $hNum2 = guictrlcreateinput("012345", 55, 70, 45, 25) $hNum3 = guictrlcreateinput("01234", 105, 70, 40, 25) $hNum4 = guictrlcreateinput("012345", 150, 70, 45, 25) $hNum5 = guictrlcreateinput("0123", 200, 70, 35, 25) $hGenNum1 = guictrlcreateinput("0000", 15, 130, 35, 25) $hGenNum2 = guictrlcreateinput("000000", 55, 130, 45, 25) $hGenNum3 = guictrlcreateinput("00000", 105, 130, 40, 25) $hGenNum4 = guictrlcreateinput("000000", 150, 130, 45, 25) $hGenNum5 = guictrlcreateinput("0000", 200, 130, 35, 25) $genButton = GUICtrlCreateButton("GENERATE", ($width/2)-20, 160) guictrlcreatepic("bk.jpg", 0, 0, $width, $height) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted April 25, 2009 Share Posted April 25, 2009 Also... "Background" pictures should always be made first and disabled guictrlcreatepic("bk.jpg", 0, 0, $width, $height) guictrlsetstate( -1, $GUI_DISABLE) this way labels and buttons will function 8) Link to comment Share on other sites More sharing options...
0_00_0 Posted April 25, 2009 Author Share Posted April 25, 2009 Damn you guys are helpful. I just assumed it would be at the back because I added the other controls after it. Disabling it was definitely the smart thing to do, thats the method I took. I'm sure adding it after works too. Thanks a bunch guys! Thats all my questions for now, feel free to lock it up! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now