Jump to content
Sign in to follow this  
ConsultingJoe

count the splits

Recommended Posts

ConsultingJoe

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]

Share this post


Link to post
Share on other sites
3telnick

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 by 3telnick

Share this post


Link to post
Share on other sites
Rick

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 by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites
ConsultingJoe

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]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×