Skip to content
⌘ NSIS Forum Archive

strcmp problem

5 posts

Rolando#

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#
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
Afrow UK#
Oh yes, you are correct. Actually...

Pop $0
StrCmp $0 ...

...would be better (re-use same variable)

-Stu