Skip to content
⌘ NSIS Forum Archive

string comparison using logiclib.nsh

3 posts

pattar_g#

string comparison using logiclib.nsh

Hello all,
Am real new to NSIS, am trying to compare two
version strings, to decide whether to install the patch
or not.. Below is the code I tried.. the problem is
that, if I try "<=" it always goes into 'If' clause,
if I try "<" it always goes into 'Else'.


ReadRegStr $0 HKLM Software\XYZ\Updates "VERSION"

MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION "Version:$0"

${If} $0 < "AB10D"

MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION " is Good!!"

${Else}

MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION "is Bad??"

${EndIf}

I tried the following registry values: AB26A & AB10C

I was expecting 'is Bad??' for the first value &
'is Good!!' for the second.

Something tells me I have missed something fundamental..

Could someone please help. couldn't find a help file that
explains this.. :-(

Thanks a lot in advance

Sri
eccles#
"<" tries to compare the values numerically.

To compare as strings you need to use "S<", "S<=", etc. All available variations are described in the Include\LogicLib.nsh file.
ReadRegStr $0 HKLM Software\XYZ\Updates "VERSION"
MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION "Version:$0"
${If} $0 S< "AB10D"
MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION "is Good!!"
${Else}
MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION "is Bad??"
${EndIf}