Indigo Rose Software

Go Back   Indigo Rose Software Forums > TrueUpdate 3.5 > TrueUpdate 3.5 Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2008
Dnixon's Avatar
Dnixon Dnixon is offline
Indigo Rose Customer
 
Join Date: Jun 2007
Posts: 94
Compare File Versions - String to Number Problems

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.

Code:
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!

Last edited by Dnixon; 01-10-2008 at 06:00 PM. Reason: For further clarification
Reply With Quote
  #2  
Old 01-11-2008
Dnixon's Avatar
Dnixon Dnixon is offline
Indigo Rose Customer
 
Join Date: Jun 2007
Posts: 94
Cool

I figured it out

I found out about the bug with the string.trimRight / string.trimLeft function and rewrote the code as follows. Works great for determining which incremental patch to deliver to the user.

g_installedVersion could be a registry key value that is set when you install the software. True Update can request that key and set it to the g_installedVersion variable at runtime. g_targetVersion is coded in the server script in your True Update code.

Code:
g_installedVersion = "1.1.0.0";

t_installedVersion = String.Replace(g_installedVersion, ".0.0", "", false);
t1_installedVersion = String.Replace(t_installedVersion, "1.", "", false);


g_targetVersion = "1.4.0.0";
t_targetVersion = String.Replace(g_targetVersion, ".0.0", "", false);
t1_targetVersion = String.Replace(t_targetVersion, "1.", "", false);

i_version = (t1_targetVersion - t1_installedVersion);

if i_version == 1 then

	-- Where do you want to download the installer/patch file from and to?
	g_SourceURL = "www.whatever.com/incrementalPatch1.exe";
	g_PatchFileDest = SessionVar.Expand("%SourceFolder%\\Patches\\incrementalPatch1.exe");
	
else if specific_version == 2 then

	-- Where do you want to download the installer/patch file from and to?
	g_SourceURL = "www.whatever.com/incrementalPatch2.exe";
	g_PatchFileDest = SessionVar.Expand("%SourceFolder%\\Patches\\incrementalPatch2.exe");

else

	-- Where do you want to download the installer/patch file from and to?
	g_SourceURL = "www.whatever.com/incrementalPatch3.exe";
	g_PatchFileDest = SessionVar.Expand("%SourceFolder%\\Patches\\incrementalPatch3.exe");

end
end

Last edited by Dnixon; 01-11-2008 at 09:10 AM. Reason: to further clarify
Reply With Quote
  #3  
Old 01-14-2008
Adam's Avatar
Adam Adam is offline
Indigo Rose Staff Member
 
Join Date: May 2000
Location: Indigo Rose Software
Posts: 2,154
I am not aware of any current bugs with the String functions. Would you be able to post your findings?

Thanks for your time

Adam Kapilik
Reply With Quote
  #4  
Old 02-04-2008
Dnixon's Avatar
Dnixon Dnixon is offline
Indigo Rose Customer
 
Join Date: Jun 2007
Posts: 94
If I remember correctly, it just doesn't work. I found some other threads where people said there was a bug with the function. Here's the string I had to begin with:

"1.1.0.0"

I wanted to remove the ".0.0" from the right and the "1." from the left so I would just have a number: "1". Well it didn't actually trim the characters when the code was executed.
Reply With Quote
  #5  
Old 02-05-2008
Mark's Avatar
Mark Mark is offline
Indigo Rose Staff Member
 
Join Date: Jun 2000
Location: Indigo Rose Software
Posts: 1,773
Hi Dnixon,

Remember that the second parameter passed to String.TrimLeft() and String.TrimRight() are the characters to trim not the string to trim.

So in this example:

Code:
trimmed = String.TrimRight("1.10.0.0", "0.");
The result would be:

Code:
1.1
This is because we are trimming the characters '.' and '0' from "1.10.0.0". We are not trimming the string ".0".

So in your example when you trim ".0.0" from the right, and "1." from the left, you are actually trimming all of the characters from the string.

I hope this helps.
__________________
MSI Factory The Next Generation Intelligent Setup Builder
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jukebox Enhancements Zylo AutoPlay Media Studio 6.0 2 01-13-2007 08:39 PM
Reading Install Path From Registry Staggan Visual Patch 2.0 33 05-04-2006 11:31 AM
Hey guys... having problems writing to a text file CelticDragon AutoPlay Media Studio 4.0 1 08-11-2003 10:31 AM
Mac autostart function??? Protocol AutoPlay Media Studio 4.0 21 06-26-2003 11:25 AM
INFO: Tips for Debugging Action Lists in AutoPlay Media Studio 4.0 Support AutoPlay Media Studio 4.0 Examples 0 10-03-2002 09:38 AM


All times are GMT -6. The time now is 02:46 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software