Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 17th, 2010 | Syntax: Lua | Size: 1.16 KB | Hits: 43 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. function syntax_Example_Sum takes integer i, real r returns real //function declaration must include: the keyword "function",
  2.                                                                  //the function name, parameters (if any) and return type (if
  3.                                                                  //it returns something)
  4.   return i + r //return statements must begin with the keyword "return"
  5. endfunction //the keyword "endfunction" signals the end of a function block
  6.  
  7. function syntax_Example takes nothing returns nothing
  8.   local integer i //declaring a local variable requires the modifier "local", the variable's data type, and the variable name
  9.  local real r = 5.0 //local variable declarations must come before anything else in a function and variables may be
  10.                     //initialized on declaration
  11.  
  12.  //separated statements MUST be placed on separate lines
  13.  
  14.  set i = 6 //the keyword "set" is used to rebind variables
  15.  call syntax_Example_Sum( i, r ) //function calls must be preceded by the keyword "call"
  16.  set r = syntax_Example_Sum( i, r ) //the "call" keyword is omitted when accessing a function's return value
  17. endfunction