slayerz Posted July 17, 2007 Share Posted July 17, 2007 Hello everyone... I'd made script that will generate random no. Random(1,15,1) The prob is, I dun want it to generate same no. twice! Does anyone know how to exclude the picked no. so that it's not same no.? or, does anyone have an idea how to make a condition statement to generate other no. if the no. has been selected? AUTOIT[sup] I'm lovin' it![/sup] Link to comment Share on other sites More sharing options...
ChrisL Posted July 17, 2007 Share Posted July 17, 2007 This works for whole numbers include <array.au3> $start = 1 $end = 15 $possibilities = ($end - $start) + 1 Local $storageArray[1] While 1 $randomNumber = Random($start,$End,1) If _ArraySearch($storageArray,$randomNumber) = -1 then _ArrayAdd($storageArray,$randomNumber) ConsoleWrite($randomNumber & @crlf) ;Msgbox(0,"",$randomNumber) EndIf If Ubound($storageArray) -1 = $possibilities then ExitLoop Wend [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Zedna Posted July 17, 2007 Share Posted July 17, 2007 This for generating two numbers (never not same): $n1 = Random(1,15,1) While 1 $n2 = Random(1,15,1) If $n2 <> $n1 Then ExitLoop WEnd ConsoleWrite($n1 & @CRLF) ConsoleWrite($n2 & @CRLF) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 17, 2007 Share Posted July 17, 2007 This for generating two numbers (never not same): $n1 = Random(1,15,1) While 1 $n2 = Random(1,15,1) If $n2 <> $n1 Then ExitLoop WEnd ConsoleWrite($n1 & @CRLF) ConsoleWrite($n2 & @CRLF) Or, perhaps, isn't never not same...? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
slayerz Posted July 19, 2007 Author Share Posted July 19, 2007 Or, perhaps, isn't never not same...? Thank you so much everyone!! I'm really appreciate your time for replying my probs! Once again, thanks AUTOIT[sup] I'm lovin' it![/sup] 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