Create a simple update check?

BlitzMax Forums/BlitzMax Beginners Area/Create a simple update check?

You do need a server somewhere, but it doesnt have to be a proper web server (although it would be alot easier to maintain imo)
Id use PHP as its everywhere these days, whatever farm you land on will probably support it.

Here is a crude version checker, using a lookup table.
Put this on a server and try out some versions numbers, eg:
/check.php?version=1.0.5
/check.php?version=1.2.0
etc...
<?php
$ver = $_GET["version"];
if( !$ver) {
	echo "Oops, no version was supplied, so i am unable to figure out my thing.";
	exit;
}

$versions = array( 
	"1.0.0" => 0,
	"1.0.5" => 1,
	"1.1.0" => 2,
	"1.2.0" => 3	// current version
);

$id = $versions[$ver];
if( !$id) {
	echo "Unable to determine your version!<br>";
} else if( $id == count($versions)-1) {
	echo "You have the latest version! $ver<br>";
	exit;
} else if( $id < count($versions)-1) {
	echo "You have an outdated version: $ver<br>";
} else {
	echo "Unexpected error, please let my master know!<br>";
}
echo "Latest version is: " . KeyName($versions, count($versions)-1);


function KeyName($myArray,$pos) {
   if( ($pos < 0) || ($pos >= count($myArray))) return "NULL";
   reset($myArray);
   for( $i = 0; $i < $pos; $i++) next($myArray);
   return key($myArray);
}

?>


Alternatively you could split the version string into its components and compare them one by one, but thats left as an exercise ;)