Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Posts
    92

    Comparing numbers and booleans?

    This is the error message I am getting: "On Preload, Line 70: Attempt to compare number with string".

    I am trying to work out the logic so an Update button is disabled if the program has never been installed. Also the Update button must be enabled if installed program has a lower version than the one on the CD.

    Here is the relevant code I have so far:

    Code:
    version2 = 0000
    version2 = INIFile.GetValue(mainpath.."\\myapp.ini", "program", "version");
    appinstalled = File.DoesExist(mainpath.."\\MyApp.exe");
    Button.SetEnabled("update", false);
    if version1 > version2 and appinstalled then 
    Button.SetEnabled("update", true);
    end
    Note:
    "mainpath" contains the path to the application, its value will be NIL in new installations because the program path is read from a local INI file when program is installed.

    The error does not come up after first version of program is already installed.

  2. #2
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Even though the value of version in the ini file may be numeric, the action INIFile.GetValue returns a variable of type String. After your INIFile.GetValue statement, do this:

    version2=String.ToNumber(version2)

    That will force version2 to be numeric, then when you compare version1 and version2 (version1 > version2) you won't get the error.




    Quote Originally Posted by cchian
    This is the error message I am getting: "On Preload, Line 70: Attempt to compare number with string".

    I am trying to work out the logic so an Update button is disabled if the program has never been installed. Also the Update button must be enabled if installed program has a lower version than the one on the CD.

    Here is the relevant code I have so far:

    Code:
    version2 = 0000
    version2 = INIFile.GetValue(mainpath.."\\myapp.ini", "program", "version");
    appinstalled = File.DoesExist(mainpath.."\\MyApp.exe");
    Button.SetEnabled("update", false);
    if version1 > version2 and appinstalled then 
    Button.SetEnabled("update", true);
    end
    Note:
    "mainpath" contains the path to the application, its value will be NIL in new installations because the program path is read from a local INI file when program is installed.

    The error does not come up after first version of program is already installed.

  3. #3
    Join Date
    Apr 2001
    Posts
    92
    You are right, thank you!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts