Dnixon
01-10-2008, 05:50 PM
I am trying to compare which file version of my software is installed to what the latest version out is so I can let True Update send the appropriate incremental patch to the user. It seems so simple, but for some reason my code does not return the expected values.
I would expect that the code below would trim the "1." from the left of the g_InstalledVersion string and the ".0.0" from the right of that string leaving me with a string containing the value "10". I do the same with my 1.11.0.0 string and then convert both of those strings to numbers to perform my arithmetic. I am expecting to have a final result of 1 stored in my versions_difference variable because 11 - 10 = 1, but it doesn't happen. It's failing somewhere with the String.TrimRight and String.TrimLeft function and I have no clue why. I'm sure this is really simple, but I just can't figure out what is going wrong. Does anyone have any ideas? Attached is my code with some debugging dialog messages I've commented out.
g_InstalledVersion = "1.10.0.0";
--Dialog.Message("g_InstalledVersion", g_InstalledVersion);
g_TargetVersion = "1.11.0.0";
--Dialog.Message("g_TargetVersion", g_TargetVersion);
trim_InstalledVersion = String.TrimRight(g_InstalledVersion, ".0.0");
--Dialog.Message("trim_InstalledVersion", trim_InstalledVersion);
trim_InstalledVersion2 = String.TrimLeft(trim_InstalledVersion, "1.");
--Dialog.Message("trim_InstalledVersion2", trim_InstalledVersion2);
trim_TargetVersion = String.TrimRight(g_TargetVersion, ".0.0");
--Dialog.Message("trim_TargetVersion", trim_TargetVersion);
trim_TargetVersion2 = String.TrimLeft(trim_TargetVersion, "1.");
--Dialog.Message("trim_TargetVersion2", trim_TargetVersion2);
short_InstalledVersion = String.ToNumber(trim_InstalledVersion2);
--Dialog.Message("short_InstalledVersion", short_InstalledVersion);
short_TargetVersion = String.ToNumber(trim_TargetVersion2);
--Dialog.Message("short_TargetVersion", short_TargetVersion);
versions_difference = (short_TargetVersion - short_InstalledVersion);
Dialog.Message("versions_difference", versions_difference);
Thanks for any help anyone can offer! :)
I would expect that the code below would trim the "1." from the left of the g_InstalledVersion string and the ".0.0" from the right of that string leaving me with a string containing the value "10". I do the same with my 1.11.0.0 string and then convert both of those strings to numbers to perform my arithmetic. I am expecting to have a final result of 1 stored in my versions_difference variable because 11 - 10 = 1, but it doesn't happen. It's failing somewhere with the String.TrimRight and String.TrimLeft function and I have no clue why. I'm sure this is really simple, but I just can't figure out what is going wrong. Does anyone have any ideas? Attached is my code with some debugging dialog messages I've commented out.
g_InstalledVersion = "1.10.0.0";
--Dialog.Message("g_InstalledVersion", g_InstalledVersion);
g_TargetVersion = "1.11.0.0";
--Dialog.Message("g_TargetVersion", g_TargetVersion);
trim_InstalledVersion = String.TrimRight(g_InstalledVersion, ".0.0");
--Dialog.Message("trim_InstalledVersion", trim_InstalledVersion);
trim_InstalledVersion2 = String.TrimLeft(trim_InstalledVersion, "1.");
--Dialog.Message("trim_InstalledVersion2", trim_InstalledVersion2);
trim_TargetVersion = String.TrimRight(g_TargetVersion, ".0.0");
--Dialog.Message("trim_TargetVersion", trim_TargetVersion);
trim_TargetVersion2 = String.TrimLeft(trim_TargetVersion, "1.");
--Dialog.Message("trim_TargetVersion2", trim_TargetVersion2);
short_InstalledVersion = String.ToNumber(trim_InstalledVersion2);
--Dialog.Message("short_InstalledVersion", short_InstalledVersion);
short_TargetVersion = String.ToNumber(trim_TargetVersion2);
--Dialog.Message("short_TargetVersion", short_TargetVersion);
versions_difference = (short_TargetVersion - short_InstalledVersion);
Dialog.Message("versions_difference", versions_difference);
Thanks for any help anyone can offer! :)