Chapter 7
149
UM10372_PCNC440_Manual_0221A
PROgRAMMiNg
A subroune can be a separate le, provided the following rules are obeyed:
• The le must be named the same as your call
• The le must include a sub and endsub in the le
• The le must be in the directory Subrounes
• The le name can include lowercase leers, numbers, dashes, and underscores only
• The le can contain only a single subroune denion
• The le must end with the extension .nc
7.8.1.2 Calling a Subroutine
To execute a subroune in a program, it must be called. To call a subroune, program O~ call where
~ is the subroune name. The subroune name may be either a named le, a numbered le, or an
expression that evaluates to a valid subroune label.
Expression Example: o[#101+2] call
Named File Example: o<myle> call
Numbered File Example: o123 call
Oponal Arguments to O~call
O~ call takes up to 30 oponal arguments, which are passed to the subroune as #1, #2 , . . . , #N.
Unused parameters from #N+1 to #30 have the same value as in the calling context.
Parameters #1-#30 are local to the subroune. On return from the subroune, the values of
parameters #1 through #30 (regardless of the number of arguments) are restored to the values they
had before the call.
The following calls a subroune with three arguments:
O~ Call Example: o200 call [1] [2] [3]
Because 1 2 3 is parsed as the number 123, the parameters must be enclosed in square brackets.
Subroune bodies may be nested. Nested subrounes may only be called aer they are dened.
They may be called from other funcons, and may call themselves recursively if it makes sense to
do so. The maximum subroune nesng level is 10.
Subrounes do not have return values, but they may change the value of parameters above #30
and those changes are visible to the calling G-code. Subrounes may also change the value of global
named parameters.
NOTE: File names are lowercase leers only; o<MyFile> is converted to o<myle> by the interpreter.