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.
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.