Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

function for version comparison


4 replies to this topic

gilchrist

gilchrist
  • Members
  • 11 posts

Posted 01 December 2001 - 11:17

hi

I need to compare 2 versions, what is the function i should use.
ex.  
1.4.0.0S5
1.4.0.0S6

if i compare the 2 values ,using vercompare it says equal,but they are.

i think the vercompare uses major version no.

How to compare these 2 string to the end ?




Lucky

Lucky
  • Members
  • 119 posts

Posted 03 December 2001 - 09:18

Try if this works:

sVer1 = "1.4.0.0S5";
sVer2 = "<different version number>";
if sVer1 <= sVer2 then
  ...
else
  ...
endif;


lasenbby

lasenbby
  • Members
  • 744 posts

Posted 03 December 2001 - 14:47

Can't tell what you are comparing, your install version or a file but for files...

Remember that there are really two versions of a file.  The string version and the numerical version.  The numerical version is what IS uses and the string is what you get when you select the version tab off of properties.  Now, since you can have alphanumberic (not just numbers)  versioning, you may want to write your own function here.  And use StrCompare.  Sound easy?  Just remember that you should be comparing apples to apples and oranges to oranges; meaning that if there is a possibility of having 1.5.00.0S1 and  1.5.0000.0S1, you will have to take this into account and pad or whatever to get them the same number of chars between the ".".

I find it useful to work up a project (for debugging) that only has a few lines of code and an exit at the end of onbegin and basically check the version of a hardcoded fully qualified file.  Messagebox out the numerical version before the exit so you can actually see what you are dealing with.  There seems to be a difference between vb and c++ in that commas and periods work different.  One to them only sets the string...can't remember which one at the moment but there is the hint on the fix if you have a discrepency.

(Edited by lasenbby at 1:50 pm on Dec. 3, 2001)


gilchrist

gilchrist
  • Members
  • 11 posts

Posted 04 December 2001 - 11:32

i am comparing install versions ... Vercompare is checking the major version and not the minor version.
1.4.0S.1

major version = 1.4
minor version = 0S.1

So is there any IS function to check the entire version as such


Perotin

Perotin
  • Full Members
  • 407 posts

Posted 04 December 2001 - 13:49

Take a look into the InstallShield knowledge base ...
function VerFindFileVersion will help you to retrieve the file versions, compare has to be hand-made if vercompare really compares just the major version ..

Another piece from the kb:

Quote
The format of the versions passed must be very specific.
The strings passed to this function have to be of the following format: "vv.xx.yy.zz" where vv,xx,yy,zz are numbers in the versions you are trying to compare. All four entries must be present, in order, for the function to compare the versions properly.

notice the word "where vv,xx,yy,zz are numbers"!