EasyManua.ls Logo

Tormach PCNC 440 - 7.8.1.1 Defining a Subroutine

Tormach PCNC 440
183 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 7
148
UM10372_PCNC440_Manual_0221A
PROgRAMMiNg
The subroune keyword denes the acon associated with the subroune label. Valid subroune
keywords and their meanings are detailed in the following table.
Subroutine Keyword Meaning
Sub Begin subroune denion
Endsub End of subroune denion
Call Call the subroune
Do/while/endwhile Execute the subroune while a condion is true
Repeat/endrepeat Execute the subroune while a condion is true
If/elseif/else/endif Condionally execute the subroune
Break Break out of a while or if/elseif statement
Connue Skip remaining code and restart at top of while or repeat loop
Return Return a value
7.8.1.1 Defining a Subroutine
The sub and endsub keywords are used to dene the beginning and end a subroune. All lines of
code between the sub and endsub keywords are considered to be part of the subroune.
Sub, Endsub, Call Example:
o100 sub
G53 G00 X0 Y0 Z0 (rapid move to machine home)
o100 endsub
...
o100 call (call the subroutine here)
M02
Subrounes can either be dened in the program le or in a separate le. If the subroune is dened
in the same le as the main program that calls the subroune, it must be dened before the call
statement. For instance, this is valid:
o100 sub
G53 G00 X0 Y0 Z0 (rapid move to machine home)
o100 endsub
...
o100 call (call the subroutine here)
M02
But this is not:
o100 call (call the subroutine here)
M02
o100 sub
G53 G00 X0 Y0 Z0 (rapid move to machine home)
o100 endsub
...

Table of Contents

Other manuals for Tormach PCNC 440