{"identifier":25888,"topic":"Keywords","name":"function","text":"<code>function <i>functionName<\/i> <\/code>[<i><code>parameterList<\/i><\/code> ]     <i><code>statements<\/i> end <i>functionName<\/i> <\/code> The<code> function <\/code>keyword defines a new function handler of the specified name.  You call a function by placing parentheses after its name, enclosing any parameters within the parentheses: <br><br>\n\n <code>get deleteSpaces(\" hello \")<\/code> <br><br>\n\n The optional<code> <i>parameterList<\/i> <\/code>lets a function handler receive values sent along with the function call. <br>\n<br>\nWhen a function is called, HyperCard evaluates each item within the parenthetical list following the function's name.  When the handler begins to execute, HyperCard assigns each value to a parameter variable  in the<code> <i>parameterList<\/i><\/code>. <br><br>\n\n Use the<code> return <\/code>keyword within the function definition to have the function return a value to the handler that called it. If you don't use<code> return<\/code>, the function evaluates to<code> empty<\/code>. <br>\n","related":{"25835":"exit","61134":"param","61390":"paramCount","61645":"params","28715":"return","8578":"The message-passing order","10721":"Using parameter variables","10397":"Writing function handlers"},"examples":"","demo":"on mouseUp\n   ask \"What is your name?\"\n   if it is empty then exit mouseUp\n   answer \"Your name spelled backwards is\" && reverseString(it) & \".\"\n end mouseUp\n <br><br>\n\n <b>function<\/b> reverseString theString\n   repeat with i = the number of chars in theString down to 1\n     put char i of theString after theReversedString\n   end repeat\n   return theReversedString\n end reverseString\n <br><br>\n\n ","debug":{"9":["function functionNam"],"10":["When a function is c"]}}