I got around stuff like that( before I had CAM software) with a Macro B program but don't know if your machine has full Fanuc capability. If it does let me know and I'll try to help you out with a bit of If and Then code.
Noel.