Erik. 1 Posted December 9, 2006 (edited) Hi, I have found that you can generate a number between 300 and 3000 whit the function random: local $random = random(300, 3000, 1) The random number will be writen to an ini file as key. how to let the program first check if the number already exists and if it exists it must make a new random number so you never have the same... Could someone help me whit that? Gr Erik Edited December 9, 2006 by Erik. Hide Erik.'s signature Hide all signatures I little problem, hard to find and fix Share this post Link to post Share on other sites
The Kandie Man 5 Posted December 9, 2006 (edited) You could use a while loop and then in the while loop have it check and if it is the same continue the loop, if it isn't then exit the loop. Give me a couple min to whip something up for you. Edited December 9, 2006 by The Kandie Man Hide The Kandie Man's signature Hide all signatures "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Share this post Link to post Share on other sites
Jos 1,844 Posted December 9, 2006 Hi, I have found that you can generate a number between 300 and 3000 whit the function random: local $random = random(300, 3000, 1) The random number will be writen to an ini file as key. how to let the program first check if the number already exists and if it exists it must make a new random number so you never have the same... Could someone help me whit that? Gr Erik Do $random = random(300, 3000, 1) Until IniRead("inifile.ini","Section",$random,0)<>0 Hide Jos's signature Hide all signatures 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. Share this post Link to post Share on other sites
Erik. 1 Posted December 9, 2006 (edited) Hi, Thanks for your posts. @ JdeB The ini file has many of that random numbers.. When it has found a number whit the same as into the ini file it needs to make a new one that is not into the ini file... Will wait for you script Thanks Gr Erik Edited December 9, 2006 by Erik. Hide Erik.'s signature Hide all signatures I little problem, hard to find and fix Share this post Link to post Share on other sites
Jos 1,844 Posted December 9, 2006 Hi,Thanks for your posts.@ JdeB The ini file has many of that random numbers..When it has found a number whit the same as into the ini file it needs to make a new one that is not into the ini file...Will wait for you scriptThanksGr ErikNah ... don't wait for it ... I have given you an approach to follow ... so its up to you to build on it .... Hide Jos's signature Hide all signatures 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. Share this post Link to post Share on other sites
The Kandie Man 5 Posted December 9, 2006 Here is something i made that should do the job. Dim $i_INIValue = IniRead("inifile.ini","Section","RandomNumbKey",-1) If $i_INIValue = -1 Then Msgbox(0,"Error","Could not read the INIfile.") Exit Endif Dim $i_RandomNum While 1 $i_RandomNum = Random(300,3000,1) IF $i_RandomNum <> $i_INIValue Then ExitLoop Wend Msgbox(0,"Done!",'The number in the ini file is ' & $i_INIValue & ' and the number that was generated randomly is ' & $i_RandomNum ) Hide The Kandie Man's signature Hide all signatures "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Share this post Link to post Share on other sites
Jos 1,844 Posted December 9, 2006 Here is something i made that should do the job. Dim $i_INIValue = IniRead("inifile.ini","Section","RandomNumbKey",-1) If $i_INIValue = -1 Then Msgbox(0,"Error","Could not read the INIfile.") Exit Endif Dim $i_RandomNum While 1 $i_RandomNum = Random(300,3000,1) IF $i_RandomNum <> $i_INIValue Then ExitLoop Wend Msgbox(0,"Done!",'The number in the ini file is ' & $i_INIValue & ' and the number that was generated randomly is ' & $i_RandomNum ) This assumes the random number is the value of the key ... not the key itself ... Hide Jos's signature Hide all signatures 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. Share this post Link to post Share on other sites
The Kandie Man 5 Posted December 9, 2006 Ok, i didn't understand, try this: Dim $i_INIValue = IniRead("inifile.ini","Section","RandomNumbKey",-1) Dim $a_ReadKeys = IniReadSection ("inifile.ini", "Section" ) If $i_INIValue = -1 Then Msgbox(0,"Error","Could not read the INIfile.") Exit Endif Dim $i_intcount Dim $i_RandomNum Dim $b_success While 1 $i_RandomNum = Random(300,3000,1) $b_success = True For $i_intcount = 1 To $a_ReadKeys[0][0] IF $i_RandomNum = $a_ReadKeys[$i_intcount][1] or $i_RandomNum = $a_ReadKeys[$i_intcount][0] Then $b_success = False ExitLoop Endif Next If $b_success = True Then Exitloop Wend Msgbox(0,"Done!",'The number in the ini file is ' & $i_INIValue & ' and the number that was genereated randomly is ' & $i_RandomNum ) Hide The Kandie Man's signature Hide all signatures "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Share this post Link to post Share on other sites
Jos 1,844 Posted December 9, 2006 Still think my version is a bit less complex ... but "There are many roads leading to Rome ..." Hide Jos's signature Hide all signatures 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. Share this post Link to post Share on other sites
Thatsgreat2345 0 Posted December 10, 2006 (edited) Erik i already had put a double key prevent in yours , lol just didnt let me respond send me ur complete code cuz i delted it Edited December 10, 2006 by Thatsgreat2345 Share this post Link to post Share on other sites
Erik. 1 Posted December 10, 2006 Hi, Yes i know i have send you a message.... i only need some lines not the whole script because i want to learn of it and i want to try to edit it bij mij self... When i don't know how to make some thing i ask for a few lines and edit it so i can use it into my script... Hope you understand it Hide Erik.'s signature Hide all signatures I little problem, hard to find and fix Share this post Link to post Share on other sites