summaryrefslogtreecommitdiff
path: root/nc_files/m73-demo.ngc
blob: b420cd51a37936e5fe5ddc65ec643f6b2d5c83e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; Demonstrate saving the global state within a subroutine
; using the M73 autorestore feature
;

O<showstate> sub
(DEBUG, imperial=#<_imperial> absolute=#<_absolute> feed=#<_feed> rpm=#<_rpm>)
O<showstate> endsub


O<imperialsub> sub
M73 (save caller state in current call context, restore on return or endsub)
;
g20 (imperial)
g91 (relative mode)
F5 (low feed)
S300 (low rpm)
;
(debug, in subroutine, state now:)
o<showstate> call
(debug, arg=#1)
o<test_return> if [[#1] GT 0]
; if called with param #1 > 0, demonstrate restore-on-return
(debug, executing return)
o<test_return> return
o<test_return> endif

; note - no exit M7x code needed - the following endsub or an
; explicit 'return' will restore caller state
(debug, executing endsub)
O<imperialsub> endsub


; main program
g21 (metric)
g90 (absolute)
f200 (fast speed)
S2500 (high rpm)
;
(debug, in main after endsub, state now:)
o<showstate> call
;
; show restore-on-endsub:
o<imperialsub> call [0]
;
(debug, back in main after return, state now:)
o<showstate> call
; now show restore-on-return:
o<imperialsub> call [1]
;
(debug, back in main, state now:)
o<showstate> call
;
m2