Abort: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m moved Abort() to Abort
imported>StDoodle
mNo edit summary
Line 1: Line 1:
'''abort([string message])'''
{{FunctionPage |
<br />Aborts the current script, printing the message passed in red. If no message is passed, it will display the all-too-familiar "KoLMafia declares world peace."
page_name=abort|
<br />Note: "abort" is also usable as a CLI command, and will not be queued.
function_category=Miscellaneous|
 
function1_return_type=void|
<p><pre># useless function, but serves as a code snippet
function2_return_type=void|
void do_ns_maze()
function2_parameter1={{Param|string|message}} |
if (item_amount($item[hedge maze puzzle]) < 1) abort("You have no puzzle pieces, man.");
function2_parameter1_desc=Where ''message'' is optional text to display in place of "KoLmafia declares world peace." (Also displays in red.)|
else cli_execute("maze");
function_description=Halts all queued functions and the entire script it is called from. Often used for error-handling.|
}</pre></p>
code1={{CodeSample |
title=Code Sample|
description=This code will abort the script if run by the "wrong" character.|
code=
<syntaxhighlight lang="c">
if (my_name() != "MrPicky") {
  abort("I don't want you to run this script, mister!");
}
</syntaxhighlight>}} |
cli_equiv=Also available as the CLI command "abort," which will not be queued (similarly stops execution of all remaining commands when parsed).
}}

Revision as of 13:20, 25 February 2010

Function Syntax

Halts all queued functions and the entire script it is called from. Often used for error-handling.

Code Sample

This code will abort the script if run by the "wrong" character.

if (my_name() != "MrPicky") {
  abort("I don't want you to run this script, mister!");
}

CLI Equivalent

Also available as the CLI command "abort," which will not be queued (similarly stops execution of all remaining commands when parsed).