SRL Archive - SRL Archives

Great new Procedures and functions! Update a script automaticly!


Dark_Sniper

2007-02-17 19:41:59

The Code im releasing will update your script automaticly without the user of the script needing to do much.

////////////////////////////////////////////////////////////
// NeedUpdate(URL , VerNum : String) : Boolean; //
// Checks the URL you give it for Version number. //
// if the version number is not the same as //
// your current version number it returns true. //
////////////////////////////////////////////////////////////
// usage: NeedUpdate('http://www.google.com' , '1.0') //
// will check google for text of 1.0 //
////////////////////////////////////////////////////////////

Function NeedUpdate(URL, CurrentVer : String) : Boolean;
Var
WebPage : String;
begin
WebPage := GetPage( URL );
if not (WebPage = CurrentVer) then
Result := True;
end;

This one Checks the version number of the script and sees if it needs to be updated.


////////////////////////////////////////////////////////////
//UpdateScript(URL, FilePath, FileName, FileType : String)//
// Goes to URL givin to it takes all text on site //
// and saves it to file path given as filename givin //
////////////////////////////////////////////////////////////
//usage: UpdateScript('http://www.google.com/update.txt', //
// 'C:\', 'Google', '.txt' ) //
////////////////////////////////////////////////////////////

Procedure UpdateScript(URL, FilePath, FileName, FileType : String);
Var
WebPage : String;
FileNum : Integer;
begin
WebPage := GetPage( URL )
FileNum := ReWriteFile ( ''+FilePath+''+FileName+''+FileType+'' , true );

if( FileNum < 0 )then begin
AddtoReport('Error with updating: File Error.')
Exit;
end;


WriteFileString(FileNum, WebPage)
CloseFile(FileNum);
end;

this one Gets the text from the page and writes it to a file.


Edit: FIXED EVERYTHING WOOT!


now i can tell some people are getting ideas like oo i can so give someone a virus or o man if i use a script with this in it ill get a virus or something bad on my computer….

now you may see it like that but its impossible as far as i see it….

getpage returns the whole page in string which is text …. plain text canot give your anything bad…
it is safe

Dark_Sniper

2007-02-18 05:23:27

Wow i and i thought this code would be a big hit i mean less work ofr lot of people :p

Ron

2007-02-18 07:58:55

From: Dark_Sniper
Wow i and i thought this code would be a big hit i mean less work ofr lot of people :p


Maybe it's because you would have to setup a page with just the code on it and everyone just attaches their file to their post on forums instead. I find that much easier. Sorry.

Nice functions an idea though. :)

Boreas

2007-02-18 09:13:08

I probably won't use it but good job all the same. I don't get this part though
if( FileNum < 0 )then
Exit;

if( FileNum < 0 )then
AddtoReport('Error with updating: File Error.')
?


From: Ron
Maybe it's because you would have to setup a page with just the code on it and everyone just attaches their file to their post on forums instead.


Plus it encourages script users to go back to thread and check, and while they are there, they can post progress and bug reports.

Freddy1990

2007-02-18 09:33:56

Well, ur not the first to do this, but nice job :)

WhiteShadow

2007-02-18 12:20:08

@Boreas, when there's a file error or something it returns -1.

Nice stuff, darky. Sumilion's scripts have it too!

Wow for some reason this forum is bustin' with good code/scripts all of a sudden. :D

Dark_Sniper

2007-02-18 13:30:56

From: Boreas


Plus it encourages script users to go back to thread and check, and while they are there, they can post progress and bug reports.


Well ill make a new procedure that i have in my dark_miner….

you can click a button it'll take you to a page where you report an error.

Spky

2007-02-18 14:00:55

Bugzor:

  if( FileNum < 0 )then
Exit;

if( FileNum < 0 )then
AddtoReport('Error with updating: File Error.')

Should be:

  
if( FileNum < 0 )then
begin
AddtoReport('Error with updating: File Error.');
Exit;
end;

… I guess.

Dark_Sniper

2007-02-18 14:09:32

im not good with exit .. i forgot what it did… exit the loop or proc…

i get exit and break mixed up XD.

im guesseing exit is the one where it exits the proc and break; is where i gets out of what loop its in ?

Spky

2007-02-18 14:33:35

Exit : Exit procedure
Break : Break the loop

Dark_Sniper

2007-02-18 15:03:36

mkay :p

ill remember that.

fixed script.

Boreas

2007-02-18 20:36:01

From: Spky
Bugzor:

  if( FileNum < 0 )then
Exit;

if( FileNum < 0 )then
AddtoReport('Error with updating: File Error.')

Should be:

  
if( FileNum < 0 )then
begin
AddtoReport('Error with updating: File Error.');
Exit;
end;

… I guess.


Yea thats what I meant:D

WhiteShadow

2007-02-18 23:16:20

@Boreas - Oh, lols, my bad. ;p

Dark_Sniper

2007-02-18 23:20:47

yes thats all fixed :p

TOB

2007-02-24 23:07:39

Actually RancidKraut and I have done this with SCARlog(*sob*)