View Full Version : IF or ELSE based on version?
Presto
04-14-2006, 11:14 PM
Hello guy, I'm not sure if this can be done or not but here goes. I want to add a gray button called "Update" that will change color if there is a newer version of the project.
I was thinking of using the IF or ELSE feature but I did not see any way to check the version. not only that I would have to have the program ask the website at start up what the up-to-date version was.
Hay any one tried to do this, or can this even be done?
nrgyzer
04-15-2006, 07:48 AM
Hello, I do such with the following:
1. Download the updatefile from a server, which contains the updateinformations (e.g. the newest version of your program)
2. Read the downloaded file with TextFile.ReadToString and every of my programs have a integrated number (e.g. program.v1.0.0)
3. Then compare TextFile.ReadToString with the integrated number
4. If TextFile.ReadToString isn't the integrated number, then a newer version exists
Examplecode:
HTTP.Download("http://www.mydomain.com/updatefile.txt", _TempFolder .. "\\updatefile.txt", MODE_BINARY, 20, 80, nil, nil, nil);
if TextFile.ReadToString(_TempFolder .. "\\updatefile.txt") ~= "program.v1.0.0" then
Dialog.Message("Newer version available", "A newer version is available!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
Dialog.Message("Newer version available", "You are up to date!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
azmanar
04-15-2006, 07:53 AM
Hello, I do such with the following:
1. Download the updatefile from a server, which contains the updateinformations (e.g. the newest version of your program)
2. Read the downloaded file with TextFile.ReadToString and every of my programs have a integrated number (e.g. program.v1.0.0)
3. Then compare TextFile.ReadToString with the integrated number
4. If TextFile.ReadToString isn't the integrated number, then a newer version exists
Examplecode:
HTTP.Download("http://www.mydomain.com/updatefile.txt", _TempFolder .. "\\updatefile.txt", MODE_BINARY, 20, 80, nil, nil, nil);
if TextFile.ReadToString(_TempFolder .. "\\updatefile.txt") ~= "program.v1.0.0" then
Dialog.Message("Newer version available", "A newer version is available!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
Dialog.Message("Newer version available", "You are up to date!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
This is nice work.....nrgyzer
Presto
04-16-2006, 04:52 AM
Thank you so much nrgyzer, you are a code ninja...
I did change the code abit to fit my needs but that worked out really nice thanks. I made labels and set them to disabled and then I made paragraphs and set them so they would not be visible if or else. This way I could make a new page called update then "On Show" I added my code there that way I could show the text that applied depending on the version and hide the other text.
HTTP.Download("http://www.mydomain.com/updatefile.txt", _TempFolder .. "\\updatefile.txt", MODE_BINARY, 20, 80, nil, nil, nil);
if TextFile.ReadToString(_TempFolder .. "\\updatefile.txt") ~= "program.v1.0.0" then
Paragraph.SetVisible("updates-yes", true);
Label.SetEnabled("download-updates", true);
Label.SetEnabled("label-treasure-updates", true);
else
Paragraph.SetVisible("updates-no", true);
end
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.