Archive: Not equal comparison with strings


Not equal comparison with strings
When using the LogicLib.nsh, is it just me, or can you not do "not equal" with two strings? I've tried to do something like:

${If} $DB_PWD <> $0
MessageBox MB_ICONEXCLAMATION|MB_OK "The two passwords do not match"
Abort
${EndIf}


or something similar a few times. It will never run the inner block of code, regardless of whether $DB_PWD and $0 are equal or not. I've now got these scatterered throughout my code:

${If} $DB_PWD == $0
; This is hack, because for some reason you can't do <> comparison with strings
${Else}
MessageBox MB_ICONEXCLAMATION|MB_OK "The two passwords do not match"
Abort
${EndIf}


I can't believe I'm the first to find this, but I can't find any post or help on something like this. The LogicLib.nsi sample compares integers, but not strings. Note, it works just fine with integers.


<> is for numbers. Use !=.


Also as password checking should usually be case sensitive, you can use S!=.

Stu


Thanks, worked great. Now that I know what I'm looking for, I still can't find any documentation on S!=. Any idea where this is documented so I can provide a reference to it?


From "Inlcudes\LogicLib.nsh"

;   The following "expressions" are available:
; Standard (built-in) string tests (which are case-insensitive):
; a == b; a != b
; Additional case-insensitive string tests (using System.dll):
; a S< b; a S>= b; a S> b; a S<= b
; Case-sensitive string tests:
; a S== b; a S!= b
; Standard (built-in) signed integer tests:
; a = b; a <> b; a < b; a >= b; a > b; a <= b
; Standard (built-in) unsigned integer tests:
; a U< b; a U>= b; a U> b; a U<= b
; 64-bit integer tests (using System.dll):
; a L= b; a L<> b; a L< b; a L>= b; a L> b; a L<= b
; Built-in NSIS flag tests:
; ${Abort}; ${Errors}; ${RebootFlag}; ${Silent}
; Built-in NSIS other tests:
; ${FileExists} a
; Any conditional NSIS instruction test:
; ${Cmd} a
; Section flag tests:
; ${SectionIsSelected} a; ${SectionIsSectionGroup} a;
; ${SectionIsSectionGroupEnd} a; ${SectionIsBold} a;
; ${SectionIsReadOnly} a; ${SectionIsExpanded} a;
; ${SectionIsPartiallySelected} a