Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 3rd November 2004, 15:14   #1
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Comparing Version numbers

I want to compare two version numbers (e.g. 1.5 compared to 1.5.1). Easiest way to do that would seem to be to simply strip out the .s (giving 15 vs 151) then compare the two as integers.

How do I strip out the .s?

Thanks!

Rob
RobGrant is offline   Reply With Quote
Old 3rd November 2004, 15:16   #2
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Bearing in mind the two numbers have to be the same length before I can do that, of course... 16 vs 151 (1.6 vs 1.5.1) is not a planned alternative

In fact if any other solutions spring to mind they'd be helpfully received, thanks!

Rob
RobGrant is offline   Reply With Quote
Old 3rd November 2004, 15:17   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
http://nsis.sourceforge.net/archive/nsisweb.php?page=34

-Stu
Afrow UK is offline   Reply With Quote
Old 3rd November 2004, 15:23   #4
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Lifesaver thanks. Sorry I didn't look hard enough I'm bloomin knackered today!
RobGrant is offline   Reply With Quote
Old 8th November 2004, 09:52   #5
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Also, I've just found that it thinks that version 6 is a lower version than version 6.0. That's not the most helpful behaviour in the world, and unfortunately I don't have the scripting skill to change it myself...can anyone help?

Cheers

-rob-
RobGrant is offline   Reply With Quote
Old 8th November 2004, 16:40   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
The code looks bad, and I know of a better way to do version comparisons which would definately always work.

Let me write you a function, will take maybe an hour at most.

-Stu
Afrow UK is offline   Reply With Quote
Old 8th November 2004, 17:34   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
Ok, here it is. I've tested it a lot and it works perfectly.

http://nsis.sourceforge.net/archive/...b.php?page=643

-Stu
Afrow UK is offline   Reply With Quote
Old 9th November 2004, 08:37   #8
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Fantastic, thanks! I'll try it out now.

-rob-

P.S. wow I'm mentioned in the archive I'm famous!
RobGrant is offline   Reply With Quote
Old 23rd November 2004, 09:37   #9
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
P.S. guys just so's you know, if you want to detect the Java version number you have to:
a) Look under HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion
b) Take that previous value, look under the subkey of the same name and append to said value the value of "MicroVersion" under that subkey.

E.g. HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion is "1.4"

So look for HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion\1.4\MicroVersion, say that is 1.

So the actual version of the current Java install is 1.4.1, NOT 1.4!

Just thought that might help someone at some point...
RobGrant is offline   Reply With Quote
Old 23rd November 2004, 09:49   #10
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
And that behaviour is documented here: http://java.sun.com/j2se/1.3/runtime_win32.html.

This info also applies to the JDK, so someone might wanna update the "Detecting the JDK version" archive docs (http://nsis.sourceforge.net/archive/...nstances=0,110.

Last edited by RobGrant; 23rd November 2004 at 10:14.
RobGrant is offline   Reply With Quote
Old 23rd November 2004, 10:12   #11
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Equally, http://nsis.sourceforge.net/archive/...nstances=0,110 seems to be incorrect.
RobGrant is offline   Reply With Quote
Old 23rd November 2004, 18:08   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,310
JDK is not the same as JRE. The first Archive page does what it says it does. I haven't looked at the second one.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 24th November 2004, 11:33   #13
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
I agree that JDK isn't the same as JRE, hence my mentioning them separately. The archive page says that it will set $1 to the current version, which it does not currently do properly.

Sorry for any inconvenience caused by me pointing this stuff out, thought it might help.
RobGrant is offline   Reply With Quote
Old 24th November 2004, 11:38   #14
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Updated JDK detection attached.
Attached Files
File Type: nsi jdk detection.nsi (465 Bytes, 187 views)
RobGrant is offline   Reply With Quote
Old 24th November 2004, 11:41   #15
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
I can update the Runtime one as well (which currently kinda does it right but in a slightly roundabout way) using the proper version number comparison (so 1.4 = 1.4.0 etc), if you like.
RobGrant is offline   Reply With Quote
Old 25th November 2004, 16:24   #16
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,310
I don't think it's a good idea to append the minor version of the JRE to the JDK. As for the second example, you can create your own Archive page that uses the registry to get the version. Everyone can create an Archive page.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 26th November 2004, 07:38   #17
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
OK, that sounds cool, I'll make an archive page if/when I get some time.

Also I am of course talking about the JDK Microversion Registry entry, not the JRE Microversion.

E.g. on this machine HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion is 1.4, and HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.4\Microversion is 2.

So the JDK version is 1.4.2. Incidentally the JRE version on here is 1.5.0.
RobGrant is offline   Reply With Quote
Old 26th November 2004, 08:53   #18
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,310
The script you've attached reads the minor version from the JRE and the rest from the JDK.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 26th November 2004, 09:12   #19
RobGrant
Senior Member
 
Join Date: Sep 2004
Location: Nottingham
Posts: 263
Fair play, didn't notice that cos I adapted it from another script. The overall point I was making was not that specifically my script should be used but that the archive page should be changed...
RobGrant is offline   Reply With Quote
Reply
Go Back   Winamp 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


All times are GMT. The time now is 22:26.