Difference between pages "Talk:ASH Errors" and "Inaccessible reason"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>StDoodle
 
imported>Bale
(r9555)
 
Line 1: Line 1:
Is this like were things like <font color="#ff7000">Script parsing error (X.ash, line Y)</font> are listed?--[[User:Icon315|Icon315]] 22:33, 14 April 2010 (UTC)
+
{{
 +
#vardefine:name|inaccessible_reason}}{{
 +
#vardefine:return_type|boolean}}{{
  
:It's where they WILL be listed, once they are listed. --[[User:Bale|Bale]] 22:52, 14 April 2010 (UTC)
+
FunctionPage|
 +
name={{#var:name}}|
  
What Bale said. Also, I changed that to orange; I kept trying to click on it. :( --[[User:StDoodle|StDoodle (#1059825)]] 00:35, 15 April 2010 (UTC)
+
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type=boolean|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|coinmaster|master}}|
 +
p1desc={{pspan|master}} is the coinmaster to check|
  
Also, if anyone's feeling particularly ambitious, https://kolmafia.svn.sourceforge.net/svnroot/kolmafia/src/net/sourceforge/kolmafia/textui/Parser.java should help. Just look for all the instances of parseException. (Speaking of which, would it be useful if these were presented in the order that they're checked?) --[[User:Heeheehee|Heeheehee]] 00:17, 17 April 2010 (UTC)
+
}}|
  
I think alphabetical order would be better: this page is going to be excellent for first-time ASH scripters to understand what's wrong with their script. --[[User:Slyz|Slyz]] 10:41, 17 April 2010 (UTC)
+
function_description=Returns a sentence explaining why {{pspan|master}} is currently unavailable. If {{pspan|master}} is available, then it returns an empty string.|
  
Should we add the correct examples? Or are the fixes clear enough?
+
code1={{CodeSample|
--[[User:Slyz|Slyz]] 08:36, 18 April 2010 (UTC)
+
title=Code Sample|
 +
description=Check if a coinmaster is available and if not, explains why.|
 +
code=
 +
<syntaxhighlight>
 +
boolean check(coinmaster master) {
 +
  if(is_accessible(master))
 +
      return true;
 +
  print(master+ " is not accesible! "
 +
      + inaccessible_reason(master));
 +
  return false;
 +
}
 +
</syntaxhighlight>
 +
}}|
  
If anything particularly complicated shows, we can give both. But so far, if you can't follow as written, I'm not sure you ever will. (That's the hypothetical "you," not the specific "hey Slyz what's wrong with you, you"). --[[User:StDoodle|StDoodle (#1059825)]] 23:35, 19 April 2010 (UTC)
+
see_also={{SeeAlso|inaccessible_reason|to_coinmaster|is_coinmaster_item}}|
 
+
}}
 
 
 
 
{{CodeSample|description=The following code results in an error.
 
|code=<syntaxhighlight>
 
void my_function( string myvar = "value" )
 
{
 
  /* Do something */
 
}
 
</syntaxhighlight>}}
 
Error message: <blockquote>Cannot initialize parameter myvar (filename.ash, line X)</blockquote>
 
I'd like to add this to the article myself, but I'm not sure how to explain its exact nature. Would this message appear only in a situation like the above code? --[[User:PhilmASTErpLus|PhilmASTErpLus]] 09:30, 28 July 2010 (UTC)
 
: Looks like a conflict of functionality -- the two ways to initialize a variable are '''string myvar''' and '''string myvar = "value"'''. The only proper way to define a parameter is the former. So basically you're defining a parameter, which then gets initialized with a value. This would lead to all sorts of problems, so the parser catches this exception and throws an error. I'm not really sure why anyone would want to do this, but I guess you can add it? (fun fact: the value that you set the parameter to doesn't actually have to match the datatype for this error to appear) --[[User:Heeheehee|Heeheehee]] 16:47, 28 July 2010 (UTC)
 
  
I'm guessing he tried it for the same reason I did; in some languages, that's how you provide a default value for a parameter. It's usually functionally equivalent to having two different versions of my_function() defined, one which accepts a single string, and one which accepts no parameters, and calls the other with the default value. Usually it isn't a big deal to do things one way or the other, but the method given above can actually be much simpler if you get into a large number of overloaded versions of a single function. --[[User:StDoodle|StDoodle (#1059825)]] 18:30, 28 July 2010 (UTC)
+
[[Category:Item Management]]

Revision as of 19:52, 20 July 2011

Function Syntax

boolean inaccessible_reason(coinmaster master )

  • master is the coinmaster to check

Returns a sentence explaining why master is currently unavailable. If master is available, then it returns an empty string.

Code Sample

Check if a coinmaster is available and if not, explains why.

boolean check(coinmaster master) {
   if(is_accessible(master))
      return true;
   print(master+ " is not accesible! "
      + inaccessible_reason(master));
   return false;
}

See Also

inaccessible_reason() | to_coinmaster() | is_coinmaster_item()