Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bebot_standard_return_array [2013/09/12 22:49] (current)
Line 1: Line 1:
 +====== BeBot Standard Return Array ======
 +Many BeBot functions return an array with a standard format. There is currently no policy that module developers follow this format when their function(s) return data. 
 +
 +==== Return Array Elements ====
 +There are three elements in a BeBot Standard Return Array: bool error, string errordesc, and mixed content. ​
 +
 +<code php>
 +$return = array('​error'​ => FALSE, '​errordesc'​ => '',​ '​content'​ => ''​);​
 +</​code>​
 +
 +=== Example Usage ===
 +<code php>
 +function return_parameter($parameter)
 +{
 +    $return['​error'​] = FALSE;
 +    $return['​errordesc'​] = '';​
 +    $return['​content'​];​
 +    if (is_null($parameter))
 +    {
 +        $return['​error'​] = TRUE;
 +        $return['​errordesc'​] = '​parameter passed to function return_parameter is null.';​
 +    }
 +    else
 +    {
 +        $return['​content'​] = $parameter;
 +    }
 +}
 +
 +function calling_function($input)
 +{
 +    $result = $this -> return_parameter($input);​
 +    if ($result['​error'​])
 +    {
 +        return $result['​errordesc'​];​
 +    }
 +    else
 +    {
 +        return $result['​content'​];​
 +    }
 +}
 +</​code>​
  
 
bebot_standard_return_array.txt ยท Last modified: 2013/09/12 22:49 (external edit)
[unknown button type]
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
WikiForumIRCBugs
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki