zxzxzx Posted September 16, 2008 Share Posted September 16, 2008 Random & Don't Repeat ? How to make that function ? Thank Link to comment Share on other sites More sharing options...
DjDeep00 Posted September 16, 2008 Share Posted September 16, 2008 @zxzxzx...This is what I would do... Every time u call Random, store that number into an Array. The next time u call Random again just check to see if that number exists in that Array. If it does then call Random again and repeat until its not found in the array. I am sure there are better ways of doing this. Hope this helps. Link to comment Share on other sites More sharing options...
zxzxzx Posted September 16, 2008 Author Share Posted September 16, 2008 @zxzxzx...This is what I would do...Every time u call Random, store that number into an Array. The next time u call Random again just check to see if that number exists in that Array. If it does then call Random again and repeat until its not found in the array. I am sure there are better ways of doing this. Hope this helps.Can you make for me that function >_< Link to comment Share on other sites More sharing options...
DjDeep00 Posted September 16, 2008 Share Posted September 16, 2008 Can you make for me that function >_<Ummmm... No.. We all are here to help not do your scripts for you. Post some code and let us know if you get stuck. Link to comment Share on other sites More sharing options...
zxzxzx Posted September 16, 2008 Author Share Posted September 16, 2008 I think you are finicality Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 16, 2008 Moderators Share Posted September 16, 2008 I think you are finicalityAt least use the word in the right context.DJDeep is right. You need to start accepting responsibility for your code and start attempting things you have questions on rather than having people do it for you. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
zxzxzx Posted September 16, 2008 Author Share Posted September 16, 2008 #include <Array.au3> Local $avArray[1] $i = 0 do $add = _ArrayAdd($avArray, Random(1, 10, 1)) _ArraySearch($avArray, $add, 0, 0, 0, 1) If @error = -6 Then MsgBox(0, '1', "") EndIf $i = $i + 1 Until $i = 10 IniWrite('C:\@.ini', '1', '1',$avArray[1]) IniWrite('C:\@.ini', '1', '2',$avArray[2]) IniWrite('C:\@.ini', '1', '3',$avArray[3]) IniWrite('C:\@.ini', '1', '4',$avArray[4]) IniWrite('C:\@.ini', '1', '5',$avArray[5]) IniWrite('C:\@.ini', '1', '6',$avArray[6]) IniWrite('C:\@.ini', '1', '7',$avArray[7]) IniWrite('C:\@.ini', '1', '8',$avArray[8]) IniWrite('C:\@.ini', '1', '9',$avArray[9]) IniWrite('C:\@.ini', '1', '10',$avArray[10]) I only can make that function. It's not work >"< Help me please. Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 16, 2008 Share Posted September 16, 2008 #include <Array.au3> Local $avArray[1] $i = 0 do $add = _ArrayAdd($avArray, Random(1, 10, 1)) _ArraySearch($avArray, $add, 0, 0, 0, 1) If @error = -6 Then MsgBox(0, '1', "") EndIf $i = $i + 1 Until $i = 10 IniWrite('C:\@.ini', '1', '1',$avArray[1]) IniWrite('C:\@.ini', '1', '2',$avArray[2]) IniWrite('C:\@.ini', '1', '3',$avArray[3]) IniWrite('C:\@.ini', '1', '4',$avArray[4]) IniWrite('C:\@.ini', '1', '5',$avArray[5]) IniWrite('C:\@.ini', '1', '6',$avArray[6]) IniWrite('C:\@.ini', '1', '7',$avArray[7]) IniWrite('C:\@.ini', '1', '8',$avArray[8]) IniWrite('C:\@.ini', '1', '9',$avArray[9]) IniWrite('C:\@.ini', '1', '10',$avArray[10]) I only can make that function. It's not work >"< Help me please. Each time you get a number, add it to a string with a comma or some delimiter. Then you can use StringInStr() to test if it has been used before. The array idea requires a loop to search the array each time, and will be very slow. Just a hint... 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...
zxzxzx Posted September 16, 2008 Author Share Posted September 16, 2008 I can't. Help me please Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 16, 2008 Moderators Share Posted September 16, 2008 #include <array.au3> Local $a_num[10] = [0,1,2,3,4,5,6,7,8,9] $a_random_num = _ArrayRandomShuffle($a_num) _ArrayDisplay($a_random_num) Func _ArrayRandomShuffle($av_array, $i_lbound = 0) Local $i_ubound = UBound($av_array) - 1 Local $icc, $s_temp, $i_random For $icc = $i_lbound To $i_ubound $s_temp = $av_array[$icc] $i_random = Random($i_lbound, $i_ubound, 1) $av_array[$icc] = $av_array[$i_random] $av_array[$i_random] = $s_temp Next Return $av_array EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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