Data editing > Using subroutines in the edit > Writing your own routines > Writing subroutines in Quantum
 
Writing subroutines in Quantum
Quick reference
To define a subroutine written in the Quantum language, type:
return
subroutine
name [(var1 [,var2, ...]) ]
Quantum statements
return
at the end of the edit, just before the end statement.
More information
Subroutines written in Quantum must be placed at the end of the edit section, before the end statement, and preceded by a return, thus:
/* main edit program here
return
/* subroutines here
end
Each subroutine starts with a subroutine statement and ends with a return.
Format of subroutine statement
subroutine name[(var1, var2, ... ) ]
name
The name of the subroutine. If you define more than one subroutine their names must be unique within the first six characters of the name so, for example, sqroot and sqrt are acceptable whereas sqroot and sqroot1 are not.
var1, var2, and so on
Variables which the subroutine will use. These variables are generally referred to as the arguments of the subroutine.
See
Passing information between the edit and a subroutine
Arguments
Calling a subroutine more than once
Defining variables in a subroutine
An example of a Quantum subroutine
See also
Writing your own routines