Rolando
17th October 2004 10:16 UTC
strcmp problem
I'm trying to read a certain line from a text file to see if it needs replacing or not. Here's the code I'm using:
Push 1484
Push "$TEMP\923.txt"read
Call ReadFileLine
Pop $0
StrCmp $0 " <png layoutpos=bottom contentalign=bottomright flip=false idres=100 alpha=40 padding=rect(0,0,18,0)/>" dontreplace replace
The problem is that even though the 2 strings are equal, it still goes to the replace label instead of the dontreplace. Where did I go wrong ?
Afrow UK
17th October 2004 10:35 UTC
Try:
Push 1484
Push "$TEMP\923.txt"
Call ReadFileLine
Pop $0
Push $0
Call TrimNewLines
Pop $R0
StrCmp $0 " <png layoutpos=bottom contentalign=bottomright flip=false idres=100 alpha=40 padding=rect(0,0,18,0)/>" dontreplace replace
You need the TrimNewLines function (from NSIS docs / archive)
-Stu
Rolando
17th October 2004 10:49 UTC
Nope. It still goes to the replace label each time.
Rolando
17th October 2004 11:50 UTC
I figured it out. You probably ment:
StrCmp $R0 ...
It works that way. Thanks !
Afrow UK
17th October 2004 12:06 UTC
Oh yes, you are correct. Actually...
Pop $0
StrCmp $0 ...
...would be better (re-use same variable)
-Stu