Bertrand_M23
5th September 2006 10:24 UTC
How to check if Var1 (not integer!) is > Var2 ?
Hello everybody,
I'm looking for a code to compare 2 variables and check if Var1 is > or < to Var2.
Note : my variables are not integers so the "IntCmp" function does'nt work.
From what i've seen : "StrCmp" just allow to check if Var1 is equal to Var2.
Thanks
Bertrand
Backland
5th September 2006 13:16 UTC
I am sure i have seen a function to convery a string to int in the manual somewhere.
Try looking up IntFmt or something similar
Bertrand_M23
5th September 2006 13:21 UTC
I must add the fact that my variables are numbers and look like this :
Var1 = 4.5, Var2 = 4.6 or something else ...
Any way i had to make comparaison so as to know which one is higher than the over so your idea to convert string into integer may not work here ... well, that's my opinion but i'm a new nsis user so ... i may be wrong !
Bertrand
Backland
5th September 2006 16:33 UTC
so you want to compare decimals, which arent actually integers...
like I said, look up:
4.9.10.1 IntFmt and the approperiate format string for floats, im pretty sure that will work.
Afrow UK
5th September 2006 16:54 UTC
You could use the VersionCompare function from the Wiki.
-Stu
Bertrand_M23
5th September 2006 16:54 UTC
Thanks !
I find a solution which works (with $R9 and $R8 my variables) :
IntOp $8 $R9 - $R8
${WordFind} "$8" "-" "E+1{" $9
IfErrors notfound found
found:
;commands ...
notfound:
;commands ...
end:
In fact, i'm just looking for the "-" in $8 so as to know which variable is higher than the other and a execute commands if "-" is found or not.
Bertrand
Afrow UK
5th September 2006 16:58 UTC
You don't need to use WordFind for that really.
This will work:
IntOp $8 $R9 - $R8
StrCpy $9 $8 1
StrCmp $9 - found notfound
...
-Stu