User Tools

Site Tools


prpl:func

<- PRPL reference <- Vars and Functions

:FUNC_NAME (Function Definition)

ArgumentsResultNotation
[ - ]

Description

Defines the beginning of a function block. Choose a unique name for the function. Statements after a function block only execute if called by invoking the function with an '@FUNC_NAME' call. The end of a function block is either the end of the script or the beginning of another function, whichever comes first.

Notes:

  • Functions use the same stack and variables as the rest of the script.
  • This is useful for passing arguments.
  • The :FUNC_NAME is essentially a marker for where the script should go when @FUNC_NAME is encountered.
  • When a function finishes, the script keep executing from after the @FUNC_NAME that triggered it

See also @FUNC_NAME (call).

<!– This page is “func” on the wiki, because filenames cannot contain : –>

Examples

1 ->SomeVar
 
10 @Square Trace #Will trace 100
 
:Square # [ number - square] Describe your function
	->NumberToSquare #Take the argument left on the stack.
	<-NumberToSquare dup mul #Square the number
	<-SomeVar if
		"Something important happened" Trace
	endif
prpl/func.txt · Last modified: 2017/09/23 07:23 by kajacx