Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   How to check if Var1 (not integer!) is > Var2 ? (http://forums.winamp.com/showthread.php?t=254851)

Bertrand_M23 5th September 2006 09:24

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 12:16

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 12:21

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 15:33

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 15:54

You could use the VersionCompare function from the Wiki.

-Stu

Bertrand_M23 5th September 2006 15:54

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 15:58

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


All times are GMT. The time now is 06:00.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.