Posts Tagged ‘brings’

this brings very close the subject of ‘real’ macros

this brings very close the subject of ‘real’ macros – a sub ject needed to learn in more depth


Copyright 2005, Industrial Press Inc, New York, NY –


FANUC CNC Custom Macros


ASSIGNING VARIABLES


105


Local Variables and Nesting Levels


busbar Machine


Subprograms and mac ros can both be nested within the pro gram structure Nest ing, as a pro –


gram ming feature, means that one subprogram or one macro can call an other subprogram or a


macro, which can call an other subprogram or a macro, and so on, up to four lev els deep Having a


four-level depth of nest ing offers some real pro gram ming power, but it is rather Busway Press Clamp Machine rare to pro gram


more than two lev els of nest ing depth Re gard less of how many lev els the macro (or subprogram)


is nested, it is im por tant to un der stand the re la tion ship be tween lo drilling steel cal vari ables and each macro


level Fig ure 18 is a sche matic rep re sen ta tion of the macro nest ing, show ing all four levels:


O0001


O9001


O9002


O9003


O9004


(MAIN)


(SUBPRG)


(SUBPRG)


(SUBPRG)


(SUBPRG)


#1=


#1=


#1=


#1=


#1=


#33=


#33=


#33=


#33=


#33=


G65 P9001 —


G65 P9002 —


G65 P9003 —


G65 P9004 —


M30


M99


M99


M99


M99


%


%


%


%


Figure18


Local variables definitions and levels of macro nesting


As the il lus tra tion shows, each set of lo cal vari ables #1 to #33 can be de fined up to five times –


once in the main pro gram, and once for each macro level (up to four more times)


Ev ery time a new nest ing level is pro cessed, the new set of vari ables takes over for that macro,


but the old set is still in mem ory, and will be re called when the macro re turns to the level it orig i –


nated from The vari ables will still re tain their val ues Re mem ber that it is the mis cel la neous func best mill drill


tion M99 that clears all lo cal vari ables, not a jump to an other pro gram Un til the pro gram flow


en coun ters the M99 func tion (end of subprogram or a macro), no lo cal vari able is cleared When


the whole pro gram is com pleted, pro gram end func tion M30 will clear any a