Old 11th February 2008, 08:04   #1
xirisone
Junior Member
 
Join Date: Feb 2007
Posts: 19
WordFind can't count?

Hi,

I want to detect whether a substring is present in a string.
I try to count how often a substring occurs in a string using WordFind...

As long as the substring occurs at least once it works.
But if the the substring is not present at all I don't get '0' as expected (and needed!) but I get the string I searched in as result.

Any Ideas?

Sample:
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0
detailprint "found 'sys' [$R0] times." // Ok, result = 2

${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "xyz" "*" $R0
detailprint "found 'xyz' [$R0] times."
This fails, $R0 contains "C:\io.sys C:\logo.sys C:\WINDOWS"

xirisone
xirisone is offline   Reply With Quote
Old 11th February 2008, 19:32   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
As the documentation says, if you don't use E in the options, you get the input string back in case of errors.
Quote:
If some errors found then (result=input string)
Use the E option and check for the error specifying zero delimiters or just compare the result to the input string.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 12th February 2008, 16:56   #3
xirisone
Junior Member
 
Join Date: Feb 2007
Posts: 19
@kichik
I'll check that out.

Still I have a problem of understanding... I'd say the result of '0' times found is a valid result and no error. The function should simply return '0'. The documentation even says the code I used is a sample for counting.
xirisone
xirisone is offline   Reply With Quote
Old 12th February 2008, 20:42   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Where exactly does the documentation say that? I can't find it.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th February 2008, 07:25   #5
xirisone
Junior Member
 
Join Date: Feb 2007
Posts: 19
The documentation at 'E.3.2 WordFind' says:

Quote:
Example (Sum of delimiters):

Section
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0
; $R0="2"
SectionEnd
My interpretation was, that I get the count how often the delimiter is found and '0' times found is a valid result (thought it worked without using the E parameter).
The problem itself is easy enough to solve, it's just for my understanding.
TIA,
xirisone
xirisone is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump