PDA

View Full Version : IF THEN test not doing what expected



NewsArchive
03-15-2009, 03:20 AM
I'm trying to detect if MSSQL CE 3.5 is already installed on a local
computer before asking the user if they want to install it.

So I decided to get file information from the SQLCECOMPACT35.DLL if it
exist and then compare that against the current version information.

However the following code does not work as expected. What am I doing
wrong or how is a better way of handling this?

******** Code extracts (not complete) **********

<< code snipped >>
Set Variable %SQLCEINSTALLED% to "0"

<< code snipped >>
Set Variable %SQLCEINSTALLED% to FUNCTION:Get File Information(File
Version (Resource)) of file "%PROGRAMFILESDIR%\MICROSOFT SQL SERVER
COMPACT EDITION\V3.5\SQLCECOMPACT35.DLL"

If %SQLCEINSTALLED% Greater Than or Equal "3.5.5692.1" Then
Set Variable %INSTALL_SQL35% to "0"
Else
Set Variable %INSTALL_SQL35% to "1"
End

<< code snipped >>

************* End Code Extracts **************

I have stepped through with the debugger and the DLL file version is
"3.5.5692.0" but the IF test is treating it as TRUE instead of FALSE.
Since I am test against "3.5.5692.1", it should be LESS THEN and fall
to the code after the ELSE statement.

Thanks in advance!

Barton Whisler
Prosoft Inc.
Tampa, Florida

NewsArchive
03-15-2009, 03:21 AM
Hi Barton,

You have to use the "Version" Condition if you are comparing version
numbers!

Does this help?

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
03-16-2009, 06:41 AM
OK, will give that a try however in this particular case, the strings
are identical except for the last character. For this one case,
shouldn't the test work anyway?

I understand other cases where because being numbers it would not work
due to how they are represented.

Barton

NewsArchive
03-16-2009, 06:41 AM
Barton,

> OK, will give that a try however in this particular case, the strings
> are identical except for the last character. For this one case,
> shouldn't the test work anyway?

You are trying to compare strings, but "Greater Than Or Equal" does a
numeric comparison. So the test does not work.

> I understand other cases where because being numbers it would not work
> due to how they are represented.

You should use the Version comparison option to compare version numbers or
(new in the latest SB6 build) the "String Greater Than or Equal" option
should also work in your case.

If %SQLCEINSTALLED% String Greater Than or Equal "3.5.5692.1" Then
! Yada
End

But I would always use the Version option to do a version comparison.

Does this help?

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner