Archive: WordFunc does not work as expected. Bug?


WordFunc does not work as expected. Bug?
The code:

${WordFind} "1|999|severnam1|r1|p1||||||||||||||" "|" "+3" $0
DetailPrint "3rd=$0"

${WordFind} "1|999|severnam1|r1|p1||||||||||||||" "|" "+9" $0
DetailPrint "9rd=$0"

${WordFind} "1|999|severnam1|r1|p1||||||||||||||" "|" "+1" $0
DetailPrint "1st=$0"

Produces:

3rd=severnam1
9rd=1|999|severnam1|r1|p1||||||||||||||
1st=1
Completed

I would except the 9th to be empty?

I am using the right function? Or am I supposed to check that the return is the same as the search string?


BTW I'm using WordFun 3.3 with NSIS v2.21


To fix this issue:

!include "WordFunc.nsh"
!insertmacro WordFind

!macro WordFindFixedCall STR DEL COL RET
${WordFind} ${STR} ${DEL} ${COL} ${RET}
StrCmp "${STR}" "${RET}" 0 +2
StrCpy ${RET} ""
!macroend
!define WordFindFixed `!insertmacro WordFindFixedCall`


${WordFind} "1|999|severnam1|r1|p1||||||||||||||" "|" "E+9" $0
IfErrors 0 +2
StrCpy $0 ""

DetailPrint "9rd=$0"

This is fair enough and will work, but it means you always have to add the 'E' and always have to check for errors. Yours effectively does the same as mine. We, and everyone else in the world, will have to add this check and compare. So why not incorporate it into the WordFind.nsh ?


Any other comments on this? What is the expected behavior? In case of error, return the entire string or an empty string when no error handling is used?


No bug. Expected behavior is entire string.


The wiki does say that the entire string is output when an error occurs and the 'E' switch is not used, but why is the case above considered an error? I would have expected it to return a null string.

Don