ravenfyre Posted August 30, 2004 Share Posted August 30, 2004 I have a string that returns an array. The number of delimeters vary from 3 to 6 and the first 2 delimeters are not important for the function and are excluded. I have a For-Next loop, and how many times it will loop depends on how many delimeters are in the array, subtracted by 2 because as I said the first 2 are not important here. Currently inside the loop I have it select the delimeters in order starting with the 3rd. I don't want to do this though. I need the script to select one of the delimeters, not in any order. I thought of using the random function but the problem with random is sometimes it picks the same number as before. Since this loop ONLY loops as many times as there are delimeters-2, this is unacceptable. I need within each loop to pick a delimeter, but as I said not in any order and it cannot select one twice. An example of a string that's being split into an array might be 0,0,1,2,3. In this example it will loop 3 times, selecting either 1,2 or 3. I don't want it in any order. 2,1,3 3,2,1 1,2,3 3,1,2 etc. For $count=1 to $con[0]-2; loops as many times as there are delimeters-2 $num = $con[$count+2]; selects the next delimeter(this one in order) The loop is definitely what's throwing me off, any suggestions would be greatly appreciated. Link to comment Share on other sites More sharing options...
scriptkitty Posted August 30, 2004 Share Posted August 30, 2004 (edited) Maybe this will get you started. $x="A,B,C" $delim=StringSplit($x,",") $old="" while StringLen ($old)<$delim[0] $y=int(Random ( 1,$delim[0]+1 ) ) if stringinstr($old,$y)>0 then else msgbox(1,$delim[$y],"Random this time was:" & $y) $old=$old & $y endif wend Edited August 30, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. 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