davidnewcomb
7th November 2006 15:49 UTC
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?
davidnewcomb
7th November 2006 15:51 UTC
BTW I'm using WordFun 3.3 with NSIS v2.21
davidnewcomb
8th November 2006 17:58 UTC
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`
Instructor
8th November 2006 18:44 UTC
${WordFind} "1|999|severnam1|r1|p1||||||||||||||" "|" "E+9" $0
IfErrors 0 +2
StrCpy $0 ""
DetailPrint "9rd=$0"
davidnewcomb
9th November 2006 09:51 UTC
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 ?
kichik
24th November 2006 12:56 UTC
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?
Instructor
24th November 2006 19:13 UTC
No bug. Expected behavior is entire string.
demiller9
25th November 2006 14:49 UTC
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