Question: how to write g code?
Answer: Define motion and function (G##) Declare a position (X## Y## Z##) Set a value (F## and/or S##) Select an item (T##) Switch something on and off (M##), such as coolant, spindles, indexing motion, axes locks, etc.