Interesting project
I suppose you would use an M Function. The switch activation would give input to your controller to continue with the program.
Your gcode post processer could most likely be readily modified to add or insert the name of this M function between every G01 line.