ConsultingJoe Posted May 29, 2006 Share 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 [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
3telnick Posted May 29, 2006 Share 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 Link to comment Share on other sites More sharing options...
Rick Posted May 29, 2006 Share 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!! Link to comment Share on other sites More sharing options...
ConsultingJoe Posted May 29, 2006 Author Share 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. [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] 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