.function <function-name> { <statements> }
.function <function-name> ( <parameter-list> ) { <statements> }
The .function statement associates an optional parameter‑list and a set of statements with function‑name.
The parameter‑list specifies one or more variable names. These variables are local to the function's statement block.
.function helloworld {
.print 'hello world';
}
.function hello (arg) {
# remember to use double quotes
.print "hello ${arg}";
}
.function print2 (a b) {
.print "${a} ${b}";
}
A function with no arguments is simply called by using the function name.
helloworld;
A function call with arguments is passed the arguments as separate values.
hello 'to you';
.set a 'to them';
hello ${a};
print2 'hello' 'world';