Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 23rd April 2007, 03:47   #1
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
WordFind bug

This is a function included with NSIS, but I'm not sure whether this would be considered a problem in NSIS or just the external function, so I'll report it here.

To Kichik:
If you feel this should be reported as a bug in NSIS, let me know.

Details
Here's the example code:
code:
OutFile "testme.exe"
ShowInstDetails show
!include WordFunc.nsh
!insertmacro WordFind
!define String "one|two|three|four|five"

Section
DetailPrint "String = ${String}"
DetailPrint '${WordFind} "${String}" "three" "#" $1'
${WordFind} "${String}" "three" "#" $1
DetailPrint "Answer: $1"
Strcpy $1 ""
DetailPrint "Example in manaual:"
DetailPrint '${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $1'
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $1

DetailPrint "answer: $1"

SectionEnd



The answer for the first WordFind call returns 2, when it should only be 1. But, the function works fine when you are dealing with paths (from the 2nd WordFind call above)
Comperio is offline   Reply With Quote
Old 23rd April 2007, 07:28   #2
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 665
code:
${WordFind} "${String}" "three" "*" $1
Instructor is offline   Reply With Quote
Old 23rd April 2007, 14:46   #3
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
OK, I see the problem:

The docs say "*" is supposed to return the number of delimiters, while "#" is supposed to return the sum of the words.

I can see that your example works and now understand why:
It's because the "*" counts delimiters and it seems that delimiters can never be the first in the list.

So, your example works for the "three", but if I change to look for "one", then it returns the "1" for both.

I still think there's a bug here. If "#" works like is documented, then it should return the same number regardless of whether the item to be searched in in the beginning or middle of the string.
Comperio is offline   Reply With Quote
Old 23rd April 2007, 15:00   #4
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 665
Where is no bug. What you are trying to do?
Instructor is offline   Reply With Quote
Old 23rd April 2007, 16:53   #5
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
I'm trying to count how many times a word appears in a delimited list.

also:
To make it clear, your suggestion does work, but doesn't appear to follow the documentation for reasons outlined in my last post.
Comperio is offline   Reply With Quote
Old 23rd April 2007, 17:01   #6
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Nevermind...
I was playing around some more and finally see why:

In my example, "three" is considered a delimiter. So between the delimiter, there are actually 2 "words":
"one|two|" and "|four"

But only one "delimiter":
"three"

I guess it just didn't make sense to me following the examples. But after I read closer the actual description, it finally started to make sense.

Thanks, Instructor.
Comperio is offline   Reply With Quote
Reply
Go Back   Winamp 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