WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Error in WordFind ?
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
xbarns
Senior Member

Registered: Aug 2007
From: Frankfurt, Germany

Error in WordFind ?

Hello all,

i have a strange problem occuring here, i use the following code to count how many times a String appears in a another String (seperated by ,). But for some reason its counted wrong BCDE are definitely only contained once!

code:
Var /Global LicenseFeatures Var /Global TESTA Var /Global TESTB Var /Global TESTC Var /Global TESTD Var /Global TESTE Var /Global TESTF Section TEST StrCpy $LicenseFeatures "A,B,C,D,E,F" ${WordFind} "$LicenseFeatures" "A" "#" $TESTA ${WordFind} "$LicenseFeatures" "B" "#" $TESTB ${WordFind} "$LicenseFeatures" "C" "#" $TESTC ${WordFind} "$LicenseFeatures" "D" "#" $TESTD ${WordFind} "$LicenseFeatures" "E" "#" $TESTE ${WordFind} "$LicenseFeatures" "F" "#" $TESTF MessageBox MB_OK "LicenseFeatures: $LicenseFeatures $\r$\n \ A: $TESTA $\r$\n \ B: $TESTB $\r$\n \ C: $TESTC $\r$\n \ D: $TESTD $\r$\n \ E: $TESTE $\r$\n \ F: $TESTF $\r$\n" SectionEnd


the result is:

LicenseFeatures: A,B,C,D,E,F

A: 1

B: 2

C: 2

D: 2

E: 2

F: 1

Any Ideas?

Quick Link | Report this post to a moderator | IP: Logged

xbarns is offline Old Post 11-03-2009 12:45 PM
Click Here to See the Profile for xbarns Click here to Send xbarns a Private Message Find more posts by xbarns Add xbarns to your buddy list Edit/Delete Message Reply w/Quote
Zinthose
Junior Member

Registered: May 2009
From:

When you use the "#" as the option for ${WordFind} it returns the sum of the words. What you want is "*" to return the count of delimiters.

code:
Var /Global LicenseFeatures Var /Global TESTA Var /Global TESTB Var /Global TESTC Var /Global TESTD Var /Global TESTE Var /Global TESTF Section TEST StrCpy $LicenseFeatures "A,B,C,D,E,F" ${WordFind} "$LicenseFeatures" "A" "*" $TESTA ${WordFind} "$LicenseFeatures" "B" "*" $TESTB ${WordFind} "$LicenseFeatures" "C" "*" $TESTC ${WordFind} "$LicenseFeatures" "D" "*" $TESTD ${WordFind} "$LicenseFeatures" "E" "*" $TESTE ${WordFind} "$LicenseFeatures" "F" "*" $TESTF MessageBox MB_OK "LicenseFeatures: $LicenseFeatures $\r$\n \ A: $TESTA $\r$\n \ B: $TESTB $\r$\n \ C: $TESTC $\r$\n \ D: $TESTD $\r$\n \ E: $TESTE $\r$\n \ F: $TESTF $\r$\n" SectionEnd

Quick Link | Report this post to a moderator | IP: Logged

Zinthose is offline Old Post 11-03-2009 04:23 PM
Click Here to See the Profile for Zinthose Click here to Send Zinthose a Private Message Find more posts by Zinthose Add Zinthose to your buddy list Edit/Delete Message Reply w/Quote
xbarns
Senior Member

Registered: Aug 2007
From: Frankfurt, Germany

Thanks that works, but then what is the sum of the words?

Quick Link | Report this post to a moderator | IP: Logged

xbarns is offline Old Post 11-03-2009 05:00 PM
Click Here to See the Profile for xbarns Click here to Send xbarns a Private Message Find more posts by xbarns Add xbarns to your buddy list Edit/Delete Message Reply w/Quote
Zinthose
Junior Member

Registered: May 2009
From:

Sum of words is the count of words parsed between around the delimiter. Since you only have one delimiter in a string it will always show 1 or 2.

Typically you will use it to get the count of items.

Example:

code:
${WordFind} "A,B,C,D,E,F" "," "*" $0 ; $0 = 6

Quick Link | Report this post to a moderator | IP: Logged

Zinthose is offline Old Post 11-03-2009 07:51 PM
Click Here to See the Profile for Zinthose Click here to Send Zinthose a Private Message Find more posts by Zinthose Add Zinthose to your buddy list Edit/Delete Message Reply w/Quote
xbarns
Senior Member

Registered: Aug 2007
From: Frankfurt, Germany

Thumbs up

Thanks.

Quick Link | Report this post to a moderator | IP: Logged

xbarns is offline Old Post 11-04-2009 08:12 AM
Click Here to See the Profile for xbarns Click here to Send xbarns a Private Message Find more posts by xbarns Add xbarns to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 04:39 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Error in WordFind ?
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON