Untitled
By: a guest | Mar 17th, 2010 | Syntax:
Lua | Size: 1.16 KB | Hits: 43 | Expires: Never
function syntax_Example_Sum takes integer i, real r returns real //function declaration must include: the keyword "function",
//the function name, parameters (if any) and return type (if
//it returns something)
return i + r //return statements must begin with the keyword "return"
endfunction //the keyword "endfunction" signals the end of a function block
function syntax_Example takes nothing returns nothing
local integer i //declaring a local variable requires the modifier "local", the variable's data type, and the variable name
local real r = 5.0 //local variable declarations must come before anything else in a function and variables may be
//initialized on declaration
//separated statements MUST be placed on separate lines
set i = 6 //the keyword "set" is used to rebind variables
call syntax_Example_Sum( i, r ) //function calls must be preceded by the keyword "call"
set r = syntax_Example_Sum( i, r ) //the "call" keyword is omitted when accessing a function's return value
endfunction