View previous topic :: View next topic |
Author |
Message |
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Wed Feb 19, 2003 11:10 pm Post subject: Check for new version of an app using vdsipp.dll |
|
|
This script downloads an INI file in the following format and then checks if the user has the latest version of the program.
INI File:
Quote: | [Software info]
Version=1.00 |
Code: | external vdsipp.dll
rem Version of current app.
%%CurrentVer = 1.0
INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,OFF
INTERNET HTTP,PROTOCOL,1,1
INTERNET HTTP,USERAGENT,1,"GeoTrail Corporation"
INTERNET HTTP,DOWNLOAD,1,http://www.youwebsite.net/version.ini,@PATH(%0)\version.ini
INTERNET HTTP,DESTROY,1
rem INIFILE OPEN,@path(%0)settings.ini
INIFILE OPEN,@PATH(%0)\version.ini
%%AppVersion = @INIREAD(Software info,Version)
rem Checks if there is a newer version.
IF @GREATER(%%AppVersion,%%CurrentVer)
INFO There is a new version available.@cr()You have version v%%CurrentVer.@cr()Latest version is v%%AppVersion.
Else
INFO You have the latest version.
END
rem Deletes the file before closing the app.
file delete,@PATH(%0)\version.ini
:Close
Exit |
_________________
|
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Wed Feb 19, 2003 11:19 pm Post subject: |
|
|
This one is alittel better. With this you can add not only version number, but also build number.
Code: | external vdsipp.dll
%%CurrentVer = 1.0
%%CurrentBuild = 230
INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,OFF
INTERNET HTTP,PROTOCOL,1,1
INTERNET HTTP,USERAGENT,1,"GeoTrail Corporation"
INTERNET HTTP,DOWNLOAD,1,http://www.yourwebsite.net//version.ini,@PATH(%0)\version.ini
INTERNET HTTP,DESTROY,1
rem INIFILE OPEN,@path(%0)settings.ini
INIFILE OPEN,@PATH(%0)\version.ini
%%AppVersion = @INIREAD(Software info,Version)
%%AppBuild = @INIREAD(Software info,Build)
IF @GREATER(%%AppVersion.%%AppBuild,%%CurrentVer.%%CurrentBuild)
INFO There is a new version available.@cr()You have version v%%CurrentVer.%%CurrentBuild.@cr()Latest version is v%%AppVersion.%%AppBuild.
Else
INFO You have the latest version.
END
file delete,@PATH(%0)\version.ini
:Close
Exit |
_________________
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Feb 19, 2003 11:29 pm Post subject: |
|
|
Handy code to have around. A few others have made systems that
download the updates. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
marty Professional Member
Joined: 10 May 2001 Posts: 789
|
Posted: Thu Feb 20, 2003 12:53 am Post subject: |
|
|
Yup I did one called i.Update System if you ever to try that Geotrail...its one my web site... its free too! Nice script you did there Geotrail! |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 1:06 am Post subject: |
|
|
Hi marty.
Yeah, I've tried it.
But I figured, why not try making my own
When I'm gonna learn, I might as well go all the way.
Thanks for the kind words on the code _________________
|
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Thu Feb 20, 2003 7:01 am Post subject: |
|
|
Very nice code, however here are some suggestions:
1. Use INTERNET HTTP,GET that way you do not have to save any file to disk. By using @internet(http,content,1) it will return the contents of the html/text you retrieved with the GET command.
2. Instead of having Ini format, you can simplify this for yourself and save a few bytes off the download and off your server's bandwidth usage by just putting the version number of the app only in the file '1.00'. *remember that this will be used internally and most of your software users will never see such a file so it need not be pretty, barebones will work*
3. Now you can dump the contents of the @internet(http,content,1) to a list and read the version number. This allows you to save bytes off the download and no files written to disk.
Code: |
INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,OFF
INTERNET HTTP,GET,1,http://www.whatever.com/version.txt
list create,1
list add,1,@internet(http,content,1)
warn @item(1,0)
list close,1
INTERNET HTTP,DESTROY,1
|
|
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 5:11 pm Post subject: |
|
|
Aaa didn't think of that.
Thanks for the tip _________________
|
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Feb 20, 2003 5:17 pm Post subject: |
|
|
If you only download a one-line textfile, you can also use this to display the results, without the need of having a list:
Code: | warn @internet(http,content,1) |
Or you could place it into a variable, so that you can check if it's newer then the current version (with @greater(%%version,%%newestversion))... |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 5:33 pm Post subject: |
|
|
Yeah, but I do need more than that.
For my program I need the program name, version, build, update date, download url and probably some information about the update itself. _________________
|
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Thu Feb 20, 2003 5:54 pm Post subject: |
|
|
Yup that's why using a list will allow you to lookup multiple fields, simply change the list index number to pull up the next value:
warn @item(1,0)
warn @item(1,1)
warn @item(1,2)
warn @item(1,3)
and so on.. |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 6:23 pm Post subject: |
|
|
And how would I format the update information file?
One field per line?
Like this?
App name
App version
App build _________________
|
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Feb 20, 2003 7:00 pm Post subject: |
|
|
Yes, because then you can get the information the way Prakash told. Be sure that you use the same line number for the info all the time, or use something like this:
Code: |
list create,1
rem Replace the line below with the code to download from your server...
list assign,1,appname:GeoTrail@cr()version:1.4@cr()build:0.1.7.4
list seek,1,0
if @match(1,appname:)
%%appname = @substr(@item(1),@succ(@pos(:,@item(1))),@len(@item(1)))
end
list seek,1,0
if @match(1,version:)
%%version = @substr(@item(1),@succ(@pos(:,@item(1))),@len(@item(1)))
end
list seek,1,0
if @match(1,build:)
%%build = @substr(@item(1),@succ(@pos(:,@item(1))),@len(@item(1)))
end
list close,1
info The appname is %%appname@cr()The version is %%version@cr()And the build is %%build
|
Because of the list seek and @match() commands, you can put the info where-ever you like, as long it isn't on the same line... Please note the the downloaded data should be formated like function:value... |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 8:00 pm Post subject: |
|
|
Great.
Thanks alot for the example.
I have a question about extensions.
I've seen in alot of example scripts that uses extensions that it has some extra info added to the call line like this:
external vdsinet.dll,Public Freeware Key|90257236
What does that mean? _________________
|
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Feb 20, 2003 8:04 pm Post subject: |
|
|
Those extensions are free to use in the KDE of VDS, but you have to registrate them to use them in compiled programs. The stuff after the DLL name will be used to check if you are a registrated user of it. The DLL you mentioned is created by Tommy Sools. It once was shareware, but now freeware, but you still have to use this parameters to run it, so the DLL knows you are a 'registrated' user... |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 8:10 pm Post subject: |
|
|
OK, might be a dumb question, but do I have to add the code stated above, with the same number? Or can I just make up my own? _________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|