Difference between revisions of "Get version"
Jump to navigation
Jump to search
imported>Icon315 (Created page with '{{ #vardefine:name|get_version}}{{ #vardefine:return_type|string}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate}}| r…') |
imported>PhilmASTErpLus (Added another code sample. I'm not sure whether checking for version/revision is the best method of feature detection.) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 12: | Line 12: | ||
return_also={{#var:return_also}} | return_also={{#var:return_also}} | ||
}}| | }}| | ||
+ | function_description=Returns the latest version of KoLmafia pertaining to your current build.| | ||
code1={{CodeSample| | code1={{CodeSample| | ||
title=Code Sample| | title=Code Sample| | ||
Line 21: | Line 22: | ||
string current = substring ( page, index_of ( page , "Download Now" ) , last_index_of ( page , "View all files" ) ); | string current = substring ( page, index_of ( page , "Download Now" ) , last_index_of ( page , "View all files" ) ); | ||
if (!contains_text( current , vers )) | if (!contains_text( current , vers )) | ||
− | print ("There is a new version. Go get it here http://sourceforge.net/projects/kolmafia/files/", "red"); | + | print ("There is a new version. Go get it here http://sourceforge.net/projects/kolmafia/files/", "red"); |
− | else print (" | + | else |
+ | print ("You are already using the most current version of KoLmafia.", "blue"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}}| | }}| | ||
− | + | code2={{CodeSample| | |
− | + | description=The following example prompts the user to update KoLmafia so as to handle newly introduced items and locations.| | |
− | + | code= | |
− | + | <syntaxhighlight> | |
+ | if ( to_float( get_version() ) < 14.1 ) //Check Vanya's Castle and Kegger in the Woods | ||
+ | abort( "The current version does not support Uncle P's maps. Please update KoLmafia." ); | ||
+ | </syntaxhighlight> | ||
+ | }}| | ||
+ | more_info=Note that a revision is distinct from a build in that a revision is a developer-sanctioned release of enough significance as to be promoted for the general public's use. When using a daily build, this function returns the most recent official version.| | ||
see_also={{SeeAlso|get_revision}}| | see_also={{SeeAlso|get_revision}}| | ||
}} | }} | ||
+ | [[Category:Miscellaneous Functions]] |
Latest revision as of 15:03, 30 July 2010
Function Syntax
string get_version()
Returns the latest version of KoLmafia pertaining to your current build.
Code Sample
Will tell you when there is a new version of mafia
string vers = get_version();
string page = visit_url("http://sourceforge.net/projects/kolmafia/files/");
string current = substring ( page, index_of ( page , "Download Now" ) , last_index_of ( page , "View all files" ) );
if (!contains_text( current , vers ))
print ("There is a new version. Go get it here http://sourceforge.net/projects/kolmafia/files/", "red");
else
print ("You are already using the most current version of KoLmafia.", "blue");
The following example prompts the user to update KoLmafia so as to handle newly introduced items and locations.
if ( to_float( get_version() ) < 14.1 ) //Check Vanya's Castle and Kegger in the Woods
abort( "The current version does not support Uncle P's maps. Please update KoLmafia." );
See Also
More Information
Note that a revision is distinct from a build in that a revision is a developer-sanctioned release of enough significance as to be promoted for the general public's use. When using a daily build, this function returns the most recent official version.