Program Structure
A program segment is a continuous group of words that can be processed as a unit; it is actually a section of the CNC machining program. The main body of a part machining program consists of several program segments. Most program segments are used to instruct the machine tool to complete or execute a certain action. A program segment consists of dimension words, non-dimensional words, and a program segment end instruction. When writing and printing, each program segment generally occupies one line, and this is also true when displaying the program on the screen.
Program Format
A conventional machining program consists of a start character (single-line segment), a program name (single-line segment), the program body, and a program end instruction (usually a single-line segment). There is also a program end character at the end of the program. The program start character and program end character are the same character: % in ISO code and ER in EIA code. The program end instruction can be M02 (program end) or M30 (paper tape end). CNC machine tools generally use stored program execution; in this case, the common feature of M02 and M30 is that after completing all other instructions in the program segment, they are used to stop the spindle, coolant, and feed, and reset the control system. M02 and M30 are completely equivalent when used on some machine tools (systems), but differ in others as follows: When ending a program with M02, the cursor stops at the end of the program after automatic execution; however, when ending a program with M30, the cursor and screen display automatically return to the beginning of the program after automatic execution, and the program can be run again by pressing the start button. Although M02 and M30 can be shared with other program words in a program segment, it is best to list them as a separate segment, or share a program segment only with the sequence number.

