Archive: Behavior of IntCmp


Behavior of IntCmp
Hi,

Somewhere I got the impression that if you called IntCmp on a string, that it would convert and compare as integer.

Well, I've been using it successfully on strings formatted like '001', and '002'.

Now, when trying to compare '007' with '008', it can't tell that 7 is less than 8. I'm assuming that it thinks I'm using octal or something internally... but anyway, since I'm in this situation with numbers in this format, what's the easiest way to compare them?

Thanks!


atoi and strtol(,,10) give the same result. But if all your numbers have 3 digits, you can do following:

Section "Dummy Section" SecDummy

StrCpy $0 "001"
StrCpy $1 "008"
IntCmp "1$0" "1$1" 0 +3 +5
MessageBox MB_OK "$0 is equal to $1"
Goto tend
MessageBox MB_OK "$0 is less then $1"
Goto tend
MessageBox MB_OK "$0 is bigger then $1"
tend:

sectionend


Hi Takhir!

Cool - I didn't think of pre-pending a digit, that's clever.

I might have to switch to that from the code that I wrote last night that compares individual digits.

Thanks!
Stan