Old 5th September 2006, 09:24   #1
Bertrand_M23
Junior Member
 
Join Date: Sep 2006
Posts: 12
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
Bertrand_M23 is offline   Reply With Quote
Old 5th September 2006, 12:16   #2
Backland
Senior Member
 
Join Date: Sep 2006
Posts: 150
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
Backland is offline   Reply With Quote
Old 5th September 2006, 12:21   #3
Bertrand_M23
Junior Member
 
Join Date: Sep 2006
Posts: 12
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
Bertrand_M23 is offline   Reply With Quote
Old 5th September 2006, 15:33   #4
Backland
Senior Member
 
Join Date: Sep 2006
Posts: 150
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.
Backland is offline   Reply With Quote
Old 5th September 2006, 15:54   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You could use the VersionCompare function from the Wiki.

-Stu
Afrow UK is offline   Reply With Quote
Old 5th September 2006, 15:54   #6
Bertrand_M23
Junior Member
 
Join Date: Sep 2006
Posts: 12
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
Bertrand_M23 is offline   Reply With Quote
Old 5th September 2006, 15:58   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump