This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: InstallScript - Real Number
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
12:40 PM
InstallScript - Real Number
Forgive me if this sounds stupid but I am not finding the answer. How do i compare a real number with another in InstallScript? I need to check if the version of an installed application is greater then 1.4...how do i do that!
If I declare a variable of type NUMBER, it coverts 1.4 to 1 :eek:
If I declare a variable of type NUMBER, it coverts 1.4 to 1 :eek:
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
12:52 PM
There is no built-in non-integer numeric data type in InstallScript, but see for example VerCompare...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
01:06 PM
Ah ok. Thats a limitation I think, is there any workaround?
I just tried VarCompare and it failed too...am i doing anything wrong here:
VerCompare("1.4", "1.1", VERSION) returns -1 !
I just tried VarCompare and it failed too...am i doing anything wrong here:
VerCompare("1.4", "1.1", VERSION) returns -1 !
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
01:14 PM
Perhaps try padding with zeros: "1.4.0.0" vs. "1.1.0.0"?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
01:19 PM
There is no doubt, you are genius...it worked 🙂
But why it does not work with 1.2 and 1.4? The InstallScript Help says:
szVersionInfo1 : Specifies the first version string in the following format:
.
If szVersionInfo1 is 2.1.2.0, the major version number is 2.1 and the minor version number is 2.0.
szVersionInfo2 : Specifies the second version string in the same format.
So, ideally it should work with numbers like 1.1 and 1.4?
But why it does not work with 1.2 and 1.4? The InstallScript Help says:
szVersionInfo1 : Specifies the first version string in the following format:
If szVersionInfo1 is 2.1.2.0, the major version number is 2.1 and the minor version number is 2.0.
szVersionInfo2 : Specifies the second version string in the same format.
So, ideally it should work with numbers like 1.1 and 1.4?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 14, 2008
01:31 PM
I'm not sure why the documentation uses the terminology that it does (in a.b.c.d, calling a.b the major version and c.d the minor version), but it seems to want four-field versions...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 15, 2008
03:57 PM
What I do for situations like this is to get the version on the string format as indicated in the prior post, then tokenize it into separate strings, and then convert each string to a number as in the following code snippet.
#define _PRE_MSI_VER_MAJOR 3
#define _PRE_MSI_VER_MINOR 1
function BOOL MSIVersionCheck()
number nReturn, nMajor, nMinor;
BOOL bSelected;
string szPath, szVerNum, szMajor, szMinor;
LIST listID;
begin
bSelected = FALSE;
szPath = WINSYSDIR ^ "msi.dll";
nReturn = VerGetFileVersion(szPath, szVerNum);
if (nReturn = 0) then
listID = ListCreate(STRINGLIST);
if (StrGetTokens (listID, szVerNum, ".") > 0) then
// Report the error.
MessageBox ("StrGetTokens failed.", SEVERE);
else
/*Some call it Major.minor.build.revision
others call a file version (x.x.y.y) Major (x.x) and minor (y.y)*/
nReturn = ListGetFirstString (listID, szMajor);
if (nReturn != END_OF_LIST) then
nReturn = ListGetNextString (listID, szMinor);
endif;
nReturn = StrToNum(nMinor, szMinor);
nReturn = StrToNum(nMajor, szMajor);
if (nMajor < _PRE_MSI_VER_MAJOR) then
bSelected = TRUE;
endif;
if ((nMajor = _PRE_MSI_VER_MAJOR) &&
(nMinor < _PRE_MSI_VER_MINOR)) then
bSelected = TRUE;
endif;
endif;
// Remove the list from memory.
ListDestroy (listID);
endif;
return bSelected;
end;
#define _PRE_MSI_VER_MAJOR 3
#define _PRE_MSI_VER_MINOR 1
function BOOL MSIVersionCheck()
number nReturn, nMajor, nMinor;
BOOL bSelected;
string szPath, szVerNum, szMajor, szMinor;
LIST listID;
begin
bSelected = FALSE;
szPath = WINSYSDIR ^ "msi.dll";
nReturn = VerGetFileVersion(szPath, szVerNum);
if (nReturn = 0) then
listID = ListCreate(STRINGLIST);
if (StrGetTokens (listID, szVerNum, ".") > 0) then
// Report the error.
MessageBox ("StrGetTokens failed.", SEVERE);
else
/*Some call it Major.minor.build.revision
others call a file version (x.x.y.y) Major (x.x) and minor (y.y)*/
nReturn = ListGetFirstString (listID, szMajor);
if (nReturn != END_OF_LIST) then
nReturn = ListGetNextString (listID, szMinor);
endif;
nReturn = StrToNum(nMinor, szMinor);
nReturn = StrToNum(nMajor, szMajor);
if (nMajor < _PRE_MSI_VER_MAJOR) then
bSelected = TRUE;
endif;
if ((nMajor = _PRE_MSI_VER_MAJOR) &&
(nMinor < _PRE_MSI_VER_MINOR)) then
bSelected = TRUE;
endif;
endif;
// Remove the list from memory.
ListDestroy (listID);
endif;
return bSelected;
end;