7.4

Table Of Contents
To cycle backwards through values, make startvalue larger than stopvalue, and specify a negative increment.
Example
define(&x,integer,1)
for(&x,1,1,5)
show('Line '+inttostr(&x))
crlf()
endfor()
Function @name (procedure)
Defines a new PlanetPress Talk function or procedure. If you define a function that you want to return a value, you assign that
value to the predefined variable &result on the last line of the function definition. You call the function or procedure you
define using the @name() command. See "@name (function/procedure)" (page 563).
You can reference a global function from within another global function only if the global function you are referencing already
exists.
You cannot reference a function from within itself, so recursive functions are not possible within PlanetPress Talk.
Syntax
Syntax for a function that returns a value:
function @name( arglist ): type
...
&result := return-_value
endfunction()
Syntax for a function that does not return a value (procedure):
function @name( arglist )
...
endfunction()
Arguments
name
Name to use for the function, prefixed with the @ character. The name must conform to the rules for names described in
"Names" (page 221). It is good practice to be careful naming functions that you define in different documents, to ensure that if
at some point you want to copy code between documents, the names of functions do not conflict.
arglist
List of arguments the function requires, where each element in the list has the syntax varname : type. For example, &date :
string. An ampersand always precedes the first letter of varname. A comma separates each element in the list. Note that all
arguments are pass by value (as opposed to pass by reference). Pass by value means that the function you define cannot mod-
ify any of the arguments it receives. Any modifications you make to an argument within the body of the function are made to a
local copy, and do not affect the original.
©2010 Objectif Lune Inc - 282 -