ConsultingJoe Posted May 29, 2006 Posted May 29, 2006 Ok say I have a file that contains: five|ten|three|five|six|ten|five I want to count how many of each there are between the delimiter: "|". I dont know where they are or what they are though. I just cant think how to make a function for this. the function would have to read me back something like, five=3,ten=2 three=1 six=1 I hope you guys know what I mean. Thanks a bunch Check out ConsultingJoe.com
3telnick Posted May 29, 2006 Posted May 29, 2006 (edited) use empty array. while reading file use loop to tokenize it concerning "|" delimiter. check against array if read token is already there. if "Yes" increase value for the proper item of the array. if "No" add new item with value "1". should work P.S. "token" mentioned above is string you are looking for, that is "five", "ten", "six" etc. Edited May 29, 2006 by 3telnick
Rick Posted May 29, 2006 Posted May 29, 2006 (edited) something like this??? $String="five|ten|three|five|six|ten|five" $Split=StringSplit($String,"|",0) $line="" For $z = 1 to $Split[0] $array = StringSplit($String, $Split[$z], 1) if Stringinstr($line,$Split[$z]) = 0 then $line=$line & $Split[$z] & " = " & $array[0]-1 & ", " next MsgBox(0,"",$line)Count_Splits.au3 Edited May 29, 2006 by Rick Who needs puzzles when we have AutoIt!!
ConsultingJoe Posted May 29, 2006 Author Posted May 29, 2006 something like this??? $String="five|ten|three|five|six|ten|five" $Split=StringSplit($String,"|",0) $line="" For $z = 1 to $Split[0] $array = StringSplit($String, $Split[$z], 1) if Stringinstr($line,$Split[$z]) = 0 then $line=$line & $Split[$z] & " = " & $array[0]-1 & ", " next MsgBox(0,"",$line) Thanks 3telnick and Rich. @Rick that was right on, thanks. I just kept getting confused when I was trying to do it. Check out ConsultingJoe.com
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