View Full Version : Update Application
rctshine
06-29-2006, 05:35 PM
Hello. I was wondering if you had any recommendations as to how to create an updater? Methods, etc. I looked into TU2, and while it seems easier to use, it has nowhere near the visual capabilities of AMS6. So, any ideas?
Josué Alba
06-29-2006, 07:08 PM
well i think you can start creating for example a function that enumerates the updates via a Log file maybe and then check the file and check if there is an update.
IE.
File 1 (local)
core file; 1.0.0.1
dll files: 1.0.2.1
main app; 2.0.0.1
File 2 (internet)
core file; 1.0.0.1
dll file; 1.0.2.2
main app; 2.0.0.2
so you now need to update dlls and man app. It has a special download addres for each part (can be named exactly as the version ie. dll_1.0.2.1) so you only need the version to attach to the standart name and you can download exactly what you need.
rctshine
06-29-2006, 10:13 PM
Instead, I went for a text file approach. When someone installs, it saves thier install location to the directory. So the patcher knows where to go. Then it downloads a list file (list.txt). It then reads the list file. For each line, there is a number index, a directory location, and the name of the file, each seperated by a |.
(I kept good notes of whats going on :)):
-- Download the patch file and save it to the directory
installpath = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Location", "install", true);
patchlist = HTTP.Download("http://mydomain.com/patches/list.txt", installpath.."\\patches.txt", MODE_TEXT, 20, 80, nil, nil, nil);
-- Turn the patch file into a table
patchtable = TextFile.ReadToTable(installpath.."\\patches.txt");
-- Count how many patches there are
tableamount = Table.Count(patchtable);
-- Get any patches already downloaded
currentpatches = TextFile.ReadToString(installpath.."\\current.txt");
--find the first patch that hasn't been downloaded
while (patchnum <= currentpatches) do
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find("tablereturn", "|", 1, false);
-- Set the last position of the number
tablsearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid("tablesearch", 1, tablesearch);
-- Since this patch has been downloaded, check the next one
currentnum = currentnum+1;
end
-- Begin splitting the patch strings
for count = currentnum, tableamount do
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find("tablereturn", "|", 1, false);
-- Set the last position of the number
tablsearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid("tablesearch", 1, tablesearch);
-- Insert the patch number into a table
Table.Insert(patch_numbers, currentnum, patchnum);
-- Remove the number and first | from the string
dirget = String.TrimLeft(tablereturn, patchnum.."|");
-- Look for the next sperating |
tablesearch2 = String.Find("dirget", "|", 1, false);
-- Find the last position of the directory
tablsearch2 = tablesearch2-1;
-- Get the directory name
directory = String.Mid(tablesearch2, 1, tablesearch2);
-- Insert the directory into a table
Table.Insert(patch_directories, currentnum, directory);
-- Remove the directory and the second | from the string
fileget = String.TrimLeft(tablereturn, directory.."|");
-- Your left with the filename, so insert it into the table
Table.Insert(patch_files, currentnum, fileget);
-- Get ready for the next patch line
currentnum = currentnum+1;
end
Example patch list:
1|//files//|test.txt
NOTE: This code doesn't install anything, just saves it to tables.
I now need to TEST the code. *scampers off*
rctshine
06-29-2006, 11:49 PM
Yes...well...I might need a little help with debugging this. :x
Code, after some fixes:
OnShow
Flash.Play("Flash2");
Page.StartTimer(4000);
-- Download the patch file and save it to the directory
installpath = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Program", "install", true);
patchlist = HTTP.Download("http://mydomain.com/patches/list.txt", installpath.."\\patches.txt", MODE_TEXT, 20, 80, nil, nil, nil);
-- Turn the patch file into a table
patchtable = TextFile.ReadToTable(installpath.."\\patches.txt");
-- Count how many patches there are
tableamount = Table.Count(patchtable);
-- Get any patches already downloaded
currentpatches = TextFile.ReadToString(installpath.."\\current.txt");
currentnum = 0;
--find the first patch that hasn't been downloaded
patchnum = "0";
while (patchnum <= currentpatches) do
-- Run the patch number function
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find("tablereturn", "|", 1, false);
-- Set the last position of the number
tablsearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid("tablesearch", 1, tablesearch);
-- Since this patch has been downloaded, check the next one
currentnum = currentnum+1;
end
-- Begin splitting the patch strings
for count = currentnum, tableamount do
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find("tablereturn", "|", 1, false);
-- Set the last position of the number
tablsearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid("tablesearch", 1, tablesearch);
-- Make the table
patch_numbers = {};
-- Insert the patch number into a table
Table.Insert(patch_numbers, currentnum, patchnum);
-- Remove the number and first | from the string
dirget = String.TrimLeft("tablereturn", patchnum.."|");
-- Look for the next sperating |
tablesearch2 = String.Find("dirget", "|", 1, false);
-- Find the last position of the directory
tablsearch2 = tablesearch2-1;
-- Get the directory name
directory = String.Mid(tablesearch2, 1, tablesearch2);
patch_directories = {};
-- Insert the directory into a table
Table.Insert(patch_directories, currentnum, directory);
-- Remove the directory and the second | from the string
fileget = String.TrimLeft("tablereturn", directory.."|");
-- Make files table
patch_files = {};
-- Your left with the filename, so insert it into the table
Table.Insert(patch_files, currentnum, fileget);
-- Get ready for the next patch line
currentnum = currentnum+1;
end
OnTimer
patches_dl = Table.Count(patch_numbers);
Flash.SetVisible("Flash2", false);
Label.SetVisible("Label1", false);
if (patches_dl == 0) then
username = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Program", "username", true);
Label.SetText("Label2", "Your up to date, "..username..".");
Label.SetVisible("Label2", true);
Image.SetVisible("Image2", true);
Button.SetVisible("Button1", true);
elseif (patches_dl > 0)then
Label.SetText("Label2", "You have "..patches_dl.." to download.");
Button.SetVisible("Button2", true);
else
Label.SetText("Label2", "A critical error has occured.");
Button.SetVisible("Button1", true);
end
But when it gets to the ontimer, im left with nothing but a blank page with button 2 set visible. It's odd, to say the least. Any help?
rctshine
06-30-2006, 07:58 PM
...Kerbump?
rctshine
07-01-2006, 03:00 PM
bump two...
TJ_Tigger
07-02-2006, 05:56 AM
One thing I noticed is that you have quoted a couple of variables in your code. By quoting those items you are searching the literal string "tablereturn" and not what the Table.Remove returned. I have highlighted them in red.
Flash.Play("Flash2");
Page.StartTimer(4000);
-- Download the patch file and save it to the directory
installpath = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Program", "install", true);
patchlist = HTTP.Download("http://mydomain.com/patches/list.txt", installpath.."\\patches.txt", MODE_TEXT, 20, 80, nil, nil, nil);
-- Turn the patch file into a table
patchtable = TextFile.ReadToTable(installpath.."\\patches.txt");
-- Count how many patches there are
tableamount = Table.Count(patchtable);
-- Get any patches already downloaded
currentpatches = TextFile.ReadToString(installpath.."\\current.txt");
currentnum = 0;
--find the first patch that hasn't been downloaded
patchnum = "0";
while (patchnum <= currentpatches) do
-- Run the patch number function
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find("tablereturn", "|", 1, false);
-- Set the last position of the number
tablsearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid("tablesearch", 1, tablesearch);
-- Since this patch has been downloaded, check the next one
currentnum = currentnum+1;
end
-- Begin splitting the patch strings
for count = currentnum, tableamount do
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find("tablereturn", "|", 1, false);
-- Set the last position of the number
tablsearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid("tablesearch", 1, tablesearch);
-- Make the table
patch_numbers = {};
-- Insert the patch number into a table
Table.Insert(patch_numbers, currentnum, patchnum);
-- Remove the number and first | from the string
dirget = String.TrimLeft("tablereturn", patchnum.."|");
-- Look for the next sperating |
tablesearch2 = String.Find("dirget", "|", 1, false);
-- Find the last position of the directory
tablsearch2 = tablesearch2-1;
-- Get the directory name
directory = String.Mid(tablesearch2, 1, tablesearch2);
patch_directories = {};
-- Insert the directory into a table
Table.Insert(patch_directories, currentnum, directory);
-- Remove the directory and the second | from the string
fileget = String.TrimLeft("tablereturn", directory.."|");
-- Make files table
patch_files = {};
-- Your left with the filename, so insert it into the table
Table.Insert(patch_files, currentnum, fileget);
-- Get ready for the next patch line
currentnum = currentnum+1;
end
rctshine
07-02-2006, 12:08 PM
For some reason, if I didn't, it would return errors on those lines.
TJ_Tigger
07-02-2006, 02:09 PM
That tells me the action that should generate the string failed. You can check to make sure it is a string or at least not equal to nil before you try and process it. Some minor error checking.
Any hints how to update the exe along with cdd... for example, client is running 6.0.2.0 runtime, and the 6.0.3.0 is available on server... how to overwrite a running exe?
rctshine
07-03-2006, 08:08 PM
The code is, unfortunately, still being evil. I have added in some error instances, and this is what I'm left with:
Flash.Play("Flash2");
Page.StartTimer(4000);
-- Download the patch file and save it to the directory
installpath = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Software", "install", true);
patchlist = HTTP.Download("http://mydomain.com/patches/list.txt", installpath.."\\patches.txt", MODE_TEXT, 20, 80, nil, nil, nil);
-- Turn the patch file into a table
patchtable = TextFile.ReadToTable(installpath.."\\patches.txt");
-- Count how many patches there are
tableamount = Table.Count(patchtable);
if(tableamount == 0)then
Dialog.Message("Error", "No entries in the patchlist. 1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.Exit(0);
end
-- Get any patches already downloaded
currentpatches = TextFile.ReadToTable(installpath.."\\current.txt");
currentpatchnum = Table.Count(currentpatches);
currentnum = 0;
--find the first patch that hasn't been downloaded
patchnum = 0;
while (patchnum <= currentpatchnum) do
-- Get the string from the tatchtableable
tablereturn = Table.Remove(patchtable, currentnum);
if(tablereturn == nil)then
Dialog.Message("Error", "No entries in the patchlist. 2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.ExitScript();
Application.Exit(0);
else
Dialog.Message("tablereturn", tablereturn, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
-- Find the first seperating |
tablesearch = String.Find(tablereturn, "|", 1, false);
if(tablesearch == nil)then
Dialog.Message("Error", "No entries in the patchlist. 3.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.Exit(0);
else
Dialog.Message("tablesearch", tablesearch, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
-- Set the last position of the number
tablesearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid(tablesearch, 1, tablesearch);
patchnum = String.ToNumber(patchnum);
-- Since this patch has been downloaded, check the next one
currentnum = currentnum+1;
end
-- Begin splitting the patch strings
for count = currentnum, tableamount do
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find(tablereturn, "|", 1, false);
-- Set the last position of the number
tablesearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid(tablesearch, 1, tablesearch);
-- Make the table
patch_numbers = {};
-- Insert the patch number into a table
Table.Insert(patch_numbers, currentnum, patchnum);
-- Remove the number and first | from the string
dirget = String.TrimLeft(tablereturn, patchnum.."|");
-- Look for the next sperating |
tablesearch2 = String.Find(dirget, "|", 1, false);
-- Find the last position of the directory
tablesearch2 = tablesearch2-1;
-- Get the directory name
directory = String.Mid(tablesearch2, 1, tablesearch2);
patch_directories = {};
-- Insert the directory into a table
Table.Insert(patch_directories, currentnum, directory);
-- Remove the directory and the second | from the string
fileget = String.TrimLeft(tablereturn, directory.."|");
-- Make files table
patch_files = {};
-- Your left with the filename, so insert it into the table
Table.Insert(patch_files, currentnum, fileget);
-- Get ready for the next patch line
currentnum = currentnum+1;
end
Now this is the odd part:
I'm getting "No entries in the patchlist. 2." (highlighted in red), yet its not exiting, with or without the Exitscript command. Any idea whats going on?
rctshine
07-13-2006, 03:25 PM
Ultra-bump from Page 3.
rctshine
07-14-2006, 11:55 PM
rebumping slightly. =3
rctshine
07-15-2006, 12:30 AM
Found the problem. Currentnum should have been 1 (it is now).
Here is what I have now:
OnShow:
-- Download the patch file and save it to the directory
installpath = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Software", "install", true);
patchlist = HTTP.Download("http://mysite.com/list.txt", installpath.."\\patches.txt", MODE_TEXT, 20, 80, nil, nil, nil);
-- Turn the patch file into a table
patchtable = TextFile.ReadToTable(installpath.."\\patches.txt");
-- Count how many patches there are
tableamount = Table.Count(patchtable);
if(tableamount == 0)then
Dialog.Message("Error", "No entries in the patchlist. 1.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.Exit(0);
end
-- Get any patches already downloaded
currentpatches = TextFile.ReadToTable(installpath.."\\current.txt");
currentpatchnum = Table.Count(currentpatches);
currentnum = 1;
--find the first patch that hasn't been downloaded
patchnum = 0;
while (patchnum < currentpatchnum) do
-- Get the string from the tatchtableable
tablereturn = Table.Remove(patchtable, currentnum);
if(tablereturn == nil)then
Dialog.Message("Error", "No entries in the patchlist. 2.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.ExitScript();
Application.Exit(0);
else
Dialog.Message("tablereturn", tablereturn, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
-- Find the first seperating |
tablesearch = String.Find(tablereturn, "|", 1, false);
if(tablesearch == nil)then
Dialog.Message("Error", "No entries in the patchlist. 3.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.Exit(0);
Application.ExitScript();
else
Dialog.Message("tablesearch", tablesearch, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
-- Set the last position of the number
tablesearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid(tablesearch, 1, tablesearch);
patchnum = String.ToNumber(patchnum);
-- Since this patch has been downloaded, check the next one
currentnum = currentnum+1;
end
-- Begin splitting the patch strings
for count = currentnum, tableamount do
-- Get the string from the table
tablereturn = Table.Remove(patchtable, currentnum);
-- Find the first seperating |
tablesearch = String.Find(tablereturn, "|", 1, false);
-- Set the last position of the number
tablesearch = tablesearch-1;
-- Get the patch number
patchnum = String.Mid(tablesearch, 1, tablesearch);
-- Make the table
patch_numbers = {};
-- Insert the patch number into a table
Table.Insert(patch_numbers, currentnum, patchnum);
-- Remove the number and first | from the string
dirget = String.TrimLeft(tablereturn, patchnum.."|");
-- Look for the next sperating |
tablesearch2 = String.Find(dirget, "|", 1, false);
-- Find the last position of the directory
tablesearch2 = tablesearch2-1;
-- Get the directory name
directory = String.Mid(tablesearch2, 1, tablesearch2);
patch_directories = {};
-- Insert the directory into a table
Table.Insert(patch_directories, currentnum, directory);
-- Remove the directory and the second | from the string
fileget = String.TrimLeft(tablereturn, directory.."|");
-- Make files table
patch_files = {};
-- Your left with the filename, so insert it into the table
Table.Insert(patch_files, currentnum, fileget);
-- Get ready for the next patch line
currentnum = currentnum+1;
end
Flash.Play("Flash2");
Page.StartTimer(4000);
OnTimer:
patches_dl = Table.Count(patch_numbers);
Flash.SetVisible("Flash2", false);
Label.SetVisible("Label1", false);
if (patches_dl == 0) then
username = Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\My Software", "username", true);
Label.SetText("Label2", "Your up to date, "..username..".");
Label.SetVisible("Label2", true);
Image.SetVisible("Image2", true);
Button.SetVisible("Button1", true);
elseif (patches_dl > 0)then
Label.SetText("Label2", "You have "..patches_dl.." to download.");
Button.SetVisible("Button2", true);
else
Label.SetText("Label2", "A critical error has occured.");
Button.SetVisible("Button1", true);
end
I get, in this order:
---------------------------
tablereturn
---------------------------
1|//|test.txt
---------------------------
OK
---------------------------
---------------------------
tablesearch
---------------------------
2
---------------------------
OK
---------------------------
---------------------------
Error
---------------------------
Page1 -> On Timer, Line 1: Argument 1 must be of type table.
---------------------------
OK
---------------------------
Any help? I guess its not building the table...or...something. :huh
rctshine
07-17-2006, 04:00 PM
Should I give up on getting any help with this? ._.
rctshine
07-18-2006, 06:32 PM
Bump...again...time #6. ._.
TJ_Tigger
07-19-2006, 07:19 AM
Bump...again...time #6. ._.
It is sometimes hard to test the code when it is just code, however it is easier if you are able to Export your project and post the apz file. That way people who are willing to help test your code don't have to rebuild your app to be able to test it. If you cannot share publically due to propreitary information ask for people to contact you via PM so you can send a copy that way. I will take a look again at the code to see how I can help.
Tigg
TJ_Tigger
07-19-2006, 07:37 AM
As a suggestion, you may want to add a check to see if the file exists before you read it to a table or you can check to see that the table is valid before you try and count the number of entries.
-- Get any patches already downloaded
if File.DoesExist((installpath.."\\current.txt") then
currentpatches = TextFile.ReadToTable(installpath.."\\current.txt");
currentpatchnum = Table.Count(currentpatches);
.
.
.
also I would change the code in regards to removing items from the table when you are checking for patches. You use this method
tablereturn = Table.Remove(patchtable, currentnum);
and at the end of the while statement you increment currentnum. What happens is you will start to skip items in your table. For example, lets say you have this table.
apple
banana
blueberries
strawberries
blackberries
kiwi
and you use this code to view it
nTCount = Table.Count(Fruitytable);
currentnum = 1;
while (currentnum < nTCount do
strRemoved = Table.Remove(Fruitytable, currentnum);
Dialog.Message("Fruit", strRemoved);
currentnum = currentnum+1;
end
you will get an out put like this
apple
blueberries
blackberries
ERROR Table entry not valid, (or a similar message)
The reason for this is because you remove the first entry (currentnum = 1) and then everything slides down the list, now banana is the first entry and blueberries is the second, so when you loop again, currentnum is now equal to 2 and it will grab remove blueberries from the list. currentnum then increments to three and the entry blackberries is in that entry. Is there any reason why you have to remove the entries from the table, can you do this instead.
nTCount = Table.Count(Fruitytable);
currentnum = 1;
while (currentnum < nTCount do
strRemoved = Fruitytable[currentnum]
Dialog.Message("Fruit", strRemoved);
currentnum = currentnum+1;
end
or even simpler.
for currentnum = 1, Table.Count(Fruitytable) do
Dialog.Message("Fruit", Fruitytable[currentnum]);
end
HTH
Tigg
rctshine
07-22-2006, 08:47 PM
Okay. Project attatched. Please don't steal my design. ._. Any help is appreciated.
rhosk
07-23-2006, 05:10 AM
First problem - need to update to the latest version of Autoplay Media Studio.
Latest version - 6.0.3.0
Your version - 6.0.0.0
TJ_Tigger
07-23-2006, 08:19 AM
I do recommend updating your application to the latest as there are a lot of good fixes in the latest version.
Also, is the web link for your download the path for the actual file? If it is there is no file at that location so that will cause the rest of the process to fail. I would recommend using the Application.GetLastError to determine if it was successful in downloading the file or not before you try to process the file.
Tigg
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.