PDA

View Full Version : Procedure Update(URL : string);



Obscurity
03-30-2016, 11:33 PM
I'll try to keep this short...

I'm sure many of you have seen updaters. Y'know, when someone posts a script, but they don't post the actual script; They post a script that downloads the most recent public copy of that script ( fady;'s Ivy Chop-O-Matic (https://villavu.com/forum/showthread.php?t=114228&p=1354980#post1354980), for example).

27287 solves this crap. Put simply, it does this:

Retrieves the online copy of the script
Compares it with the currently running script and if it has changed:

Overwrites the current script with the newer
Creates a .bat that:

Kills the current Simba by PID
Launches a new Simba and runs the script with:

AppPath + AppFile() + ' -o ' + ScriptPath + ScriptFile + ' -r'
Deletes itself




Now you can run a script. If there's an update, it'll automatically download and run the newer script! A bit "hackish", but works mint (from my experiences).

This works with other Simbas, even if you've renamed yours to, say, Simba_Old.exe. See below.



Update.simba provides:

AppFile() - Similar to ScriptFile, but provides the currently running Simba executable
TInputPipeStream.ReadAnsiString() - The default is broken and doesn't return correct values
Update() - Updates your current script from a URL if an update is needed




Want proof? Save and run this!
program UpdateExample;
{$I Update.simba}

const
VERSION := 1.0;

begin
Update('http://pastebin.com/raw/TdCiPkAr');
WriteLN('Version: ', VERSION);
end.
https://i.gyazo.com/e0d4bde86b43c81d884731078f27c982.gif


Thoughts? I'm sure there are better ways but meh, was fun to learn and use TProcess and such. :). Tried to make it easy enough to read.

Clarity
03-31-2016, 12:09 AM
Awesome! Going to use this :)

Turpinator
03-31-2016, 01:36 AM
Soo... now we need to have nubs download prosocks and this 'include' file, place it in the correct spot, and then download an updater?

ive considered doing an updater like this, but... the thing is... if someone cant read 'script downloaded to /path/to/script.simba, please open and run' and then do it, should they really even be using simba?

also, on 105, you dont need the proceeding file://
thats all i read.

Ross
03-31-2016, 02:36 AM
Soo... now we need to have nubs download prosocks and this 'include' file, place it in the correct spot, and then download an updater?

ive considered doing an updater like this, but... the thing is... if someone cant read 'script downloaded to /path/to/script.simba, please open and run' and then do it, should they really even be using simba?

also, on 105, you dont need the proceeding file://
thats all i read.

Just needs ProSocks which arguably should be included in Simba already, and the functions could easily be included in SRL-6.

Good work Obs.

Home
03-31-2016, 07:48 AM
I created something similar couple years ago.

https://villavu.com/forum/showthread.php?t=110662&p=1314377#post1314377

Good work :)

-Home