we are using the macro typed out below to handle the tool changes in our okuma mb56va mills and there's a certain behavior i would like to change.
when we run a program (cycle start) and the tool needed is currently in the spindle, the spindle will first drive all the way up "G0Z5000" and THEN check if the correct tool is in the spindle and THEN go back down and start the operation. what i would like to change is have to machine FIRST check if the tool is the spindle and if it's not then use "G0Z5000". and if called tool IS currently in the spindle then start operation. seems like a simple change in the code but i'm not very fluent at this kind of stuff so if anybody could do it for me i would thank you in advance

OATC1
(TOOL CHANGE MACRO)
(COMMAND IS G116 T?? Q??)
(T=DESIRED TOOL #, Q=NEXT TOOL #)
(G116 T0 WILL CLEAR TOOL FROM SPINDLE)
(FEB 5, 2004)
M329
M5
G0Z5000
IF[PT EQ 0]NMT
IF[VTLCN EQ PT] NFIN
IF[VNTOL EQ PT] NCH
IF[VNTOL EQ 0] NCHG
M64
NCHG T=PT M6
NFIN IF[VNTOL EQ 0] NTL
IF[VNTOL NE PQ] NCLR
GOTO NEND
NCH M6
GOTO NFIN
NCLR M64
NTL T=PQ
GOTO NEND
NMT IF[VNTOL EQ 0]NRID
M64
NRID M63
M6
NEND RTS