Relation:function

Define a custom function you can use in expressions.

Description

function name (was (parameter (, parameter...)))

limitedinstructionlist

set result expression

end function

Parameters

name: any valid name

parameter: any valid name

limitedinstructionlist: set, if, while

result: the last value of this variable is returned. It is always of type text.

Examples

Using the sample relation films.csv .

function even (y)
if y mod 2 = 0
set result = 1
else
set result = 0
end if
end function
read "films.csv"
extend iseven = even(year)

film director year iseven
A bout de souffle Godard 1960 1
Tirez sur le pianiste Truffaut 1960 1
Cléo de 5 à 7 Varda 1962 1
Jules et Jim Truffaut 1962 1
Pierrot le fou Godard 1965 0
Week-End Godard 1967 0
Die verlorene Ehre der Katharina Blum von Trotta 1975 0
Der starke Ferdinand Kluge 1976 1
Sans toi ni loi Varda 1985 0

Comments

Use functions when you are limited with expression or you want to reuse complicated expressions.

Functions cannot act directly on a relation. They deal with text and numbers and return text.

There is no return instruction. The last value set for result is returned.

Variable scope: Functions see only variables passed by parameters.

See also

Built in Functions