SRL Archive - News and General

Checking if a script is upToDate


HarryJames

2011-03-04 00:13:59

So I stole this off Harry ;)

Procedure ScriptUpToDate;
var ClientUp, Neifile: integer;
OnlineVersion: string;
Begin
writeln('Checking script version...');
ClientUp := InitializeHTTPClient(False);
SetHTTPUserAgent(ClientUp,'Simba/BarebonesUpdater');
OnlineVersion := GetHTTPPage(ClientUp,'http://86.17.186.225/fightcave');
if (OnlineVersion='') then exit;
if (LOCAL_VERSION = OnlineVersion) then
writeln('The script is up to date');

End;

Yes, that's my IP and yes, my web server is setup and running.

The 'fightcave' file has a number (which I will be keeping up to date) and will be for example, 120. This will be for version 1.20!

I can't find anything for 'InitializeHTTPClient', and the debugging is telling me I have included an incorrect amount of parameters.
I've searched the forum, alas with no prevail.

Harry

2011-03-04 00:28:57

InitializeHTTPClient is one parm if you don't declare SRL, and 2 parms if you do declare SRL. Both booleans, and both best left at False (HandleCookies, HandleRedirects).

I suggest getting a sub-domain name that you can update if your IP changes. Nice choice in httpd using lighttpd though! ;)

Lastly, make sure you free the HTTPClient when you're done.

HarryJames

2011-03-04 00:43:55

Thanks, I couldn't find any documentation!

I don't really want a sub domain that isn't any of the following!

.co.uk
.harry.lu
.com

I'll look around tomorrow for something free and not mysite.THISisAfreeFUCKINGdomainCLICKhereTOgetONEnow.co.nr!


Edit: (I seem to edit A LOT of my posts!)

There's a function for ToStr(), but not ToInt()?
How can I transform a string to an int?

i luffs yeww

2011-03-04 01:00:54

StrToInt().

Harry

2011-03-04 01:01:28

StrToInt() - edit: ninja.

Look through http://freedns.afraid.org/domain/registry/ - you might find something nice.

Bonfield

2011-03-04 01:04:42

StrToFloatDef(String, 0)

will try to convert the string to a float and if it fails it will return 0, although you can set this number to anything eg -1, -0.1 etc whatever you want to use

EDIT: double ninja'd

HarryJames

2011-03-04 01:04:48

I remembered I bought one, with EMA (that I didn't have).

I got a letter from the bank saying they withdrew the transaction. I still own the site somehow, and it's updating the Zone Records now!

ToStr
IntToStr

It doesn't follow the same format :(

Thanks!

HarryJames

2011-03-04 01:07:06

I'll make a new post for this!

Procedure ScriptUpToDate;
var
ClientUp: integer;
OnlineVersion: string;
Begin
writeln('Checking script version...');
ClientUp := InitializeHTTPClient(False, False);
SetHTTPUserAgent(ClientUp,'Simba/BarebonesUpdater');
OnlineVersion := GetHTTPPage(ClientUp,'http://86.17.186.225/fightcave');
FreeHTTPClient(ClientUp);

if (OnlineVersion='') then exit;
writeln(LOCAL_VERSION);
writeln(OnlineVersion);
if (LOCAL_VERSION = StrToInt(OnlineVersion)) then
writeln('The script is up to date');

End;

Debug Box;

Checking script version...
120
120

Successfully executed.

I manually stopped it. Are they still of inconsistent data types?

Edit: (I DO ALOT OF EDITS, OKAY?)

I now have this site, until mine starts working!

cycrosism

2011-03-04 05:15:19

This is the code from the version checker on my power cutter


Procedure CheckVersion;
Begin
Vv := GetPage('http://cycrosism.webs.com/willow.txt');
V := Between('/v ', ' v\', Vv);
If Version = V Then Writeln('You have the latest version ('+Version+')') Else
Begin
Writeln('Your version of the script isn''t up to date but the script will run anyway.');
Writeln('Updated version can be found at [url]http://villavu.com/forum/showthread.php?p=771486#post771486');[/url]
Wait(5000);
End;
If Version = '' Then
Begin
Writeln('Please allow the script to connect to my webpage to check the version');
Wait(2000);
TerminateScript;
End;
End;