Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.
function functionName [parameterList]
statements
end functionName
The function
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:
get deleteSpaces(" hello ")
The optional parameterList
lets a function handler receive values sent along with the function call.
When 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 parameterList
.
Use the return
keyword within the function definition to have the function return a value to the handler that called it. If you don't use return
, the function evaluates to empty
.
on mouseUp
ask "What is your name?"
if it is empty then exit mouseUp
answer "Your name spelled backwards is" && reverseString(it) & "."
end mouseUp
function reverseString theString
repeat with i = the number of chars in theString down to 1
put char i of theString after theReversedString
end repeat
return theReversedString
end reverseString
myAverage
onlyOneWindow
As in the HyperTalk examples:
function myAverage theNumbers
function onlyOneWindow
result
as a variable name.) For example:var1
var1,var2,var3, var4
fieldName, N, numberOfCharacters
put "Hello world" -- built-in command
get total(field 1) -- function call
global HelpInfo -- keyword
Keywords
Version 0.7b1 (March 24, 2022)