Relation:program

Encapsulate code in a subroutine that can be called with parameters.

Description

program name ((parameter (, parameter...)))

instructionlist

end program

Parameters

name: any valid name

parameter: any valid name

instructionlist: any instruction except function and include.

Examples

Using the sample relation films.csv .

program yearlist(y)
read "films.csv"
select year = y
print
end program
run yearlist(1960)

film director year
A bout de souffle Godard 1960
Tirez sur le pianiste Truffaut 1960

run yearlist(1962)

film director year
Cléo de 5 à 7 Varda 1962
Jules et Jim Truffaut 1962

Comments

Programs operate directly on the stack. They do not return a value.

Variable scope: Programs see the global variables outside the program, but if they change their values, they change it only locally, not globally.

Use Name indirection if you want to parametrize also names and not only values.

Use stack if you want to know the columns of the current relation.

See also

run