ASH Errors: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
No edit summary
imported>Slyz
someone might want to check the formatting
Line 3: Line 3:
Also, I don't happen to have this page done, yet.
Also, I don't happen to have this page done, yet.


===abort===
===Abort===


Whenever a script runs the [[abort|abort()]] function, this error is generated.
Whenever a script runs the [[abort|abort()]] function, this error is generated.
{{CodeSample|
description=Example|
code=
<syntaxhighlight>
abort("Aborting script...");
</syntaxhighlight>}}
will stop the execution and print: <span style="color:red">Aborting script...</span>
===Expected===
This generally indicates a syntax problem (missing ending semi-colon, unmatched braces, unmatched parenthesis etc...).
{{CodeSample|
description=Example|
code=
<syntaxhighlight>
int a = 1
print(a);
</syntaxhighlight>}}
will cause this error: <span style="color:red">Expected ;, found print (test.ash, line 2)</span>
===Missing return value===
The last line of a user-defined function has to be "return <value>;" (although the [[return]] command can be used before too).
{{CodeSample|
description=Example|
code=
<syntaxhighlight>
int my_function( int a, int b ) {
    if ( a > b ) return a ;
    else return b ;
}
</syntaxhighlight>}}
will cause this error: <span style="color:red">Missing return value (test.ash, line 4)</span>


{{RFI|Obviously, a lot more info is needed here.}}
{{RFI|Obviously, a lot more info is needed here.}}

Revision as of 17:34, 16 April 2010

Errors happen.

Also, I don't happen to have this page done, yet.

Abort

Whenever a script runs the abort() function, this error is generated.

Example

abort("Aborting script...");

will stop the execution and print: Aborting script...

Expected

This generally indicates a syntax problem (missing ending semi-colon, unmatched braces, unmatched parenthesis etc...).

Example

int a = 1
print(a);

will cause this error: Expected ;, found print (test.ash, line 2)


Missing return value

The last line of a user-defined function has to be "return <value>;" (although the return command can be used before too).

Example

int my_function( int a, int b ) {	
    if ( a > b ) return a ;
    else return b ;
}

will cause this error: Missing return value (test.ash, line 4)

Attention KoLmafia Experts!

We need your help; some details of this function's operation are unknown or unclear.

The following specific question has been raised:

  • Obviously, a lot more info is needed here.