Heidenhain TNC 640 Training 2: Entering, Editing and Deleting Programs

12 November 2026

Mentor CNC Editorial Team

Page 2 of the Heidenhain TNC 640 training series shows how to enter a program by hand at the machine, make small corrections in a program that came from CAM, and delete programs you no longer need. Every operation is laid out as a “press this, then this” table. Key and soft-key names follow the HEIDENHAIN user’s manual.

There are two program formats on a Heidenhain control: HEIDENHAIN Klartext (conversational) programs use the .H extension and DIN/ISO (G-code) programs use .I. The examples on this page are for conversational (.H) programs.

How do you create a new program on a Heidenhain control?

A program is always entered in the Programming operating mode.

Heidenhain TNC 640 new program with blank form definition in Programming mode
Programming mode: new program with the blank form (BLK FORM) dialog.
StepWhat to doWhat you see
1Press the Programming operating mode keyProgramming appears at the top right
2Press PGM MGTThe file manager opens
3Select the folder for the new program with the arrow keys–
4Type the new name with its extension, e.g. NEW.H, then ENTYou are asked for the unit of measure
5Press the MM (or INCH) soft keyThe program window opens and the blank form (BLK FORM) dialog starts
6Press the soft key for a rectangular blankPrompt: Working plane in graphic: XY
7Enter the spindle axis, e.g. ZWorkpiece blank def.: minimum
8Enter X, Y, Z of the MIN point, confirming each with ENTWorkpiece blank def.: maximum
9Enter X, Y, Z of the MAX point, confirming each with ENTThe BEGIN PGM, BLK FORM and END PGM blocks are created
BlockMeaning
0 BEGIN PGM NEW MMProgram start, name, unit of measure
1 BLK FORM 0.1 Z X+0 Y+0 Z-40Spindle axis, MIN point of the blank
2 BLK FORM 0.2 X+100 Y+100 Z+0MAX point of the blank
3 END PGM NEW MMProgram end

The control generates the block numbers and the BEGIN and END blocks itself. The blank form is only needed to test the program graphically; if you don’t want one, cancel the dialog with DEL at the Working plane in graphic prompt.

Which characters can you use in a program name?

File names should only contain these characters: A–Z a–z 0–9 . _ -. Spaces and any other characters can cause problems during data transfer. The full path including drive, directory and extension must not exceed 255 characters.

How do you enter a block in a Heidenhain program?

Each line of a Heidenhain program is called an NC block. A block starts with a dialog key (e.g. straight line L) and the control asks for the required data one by one in the header. Below is the manual’s example: L X+10 Y+5 R0 F100 M3.

Heidenhain TNC 640 block entry with miscellaneous function M soft keys
Block entry: the M function soft keys appear at the Miscellaneous function M prompt.
StepWhat to doWhat you see
1Press a path function key (straight line L)Prompt: COORDINATES?
2Axis key X, 10; axis key Y, 5; ENTPrompt: Radius comp.: RL/RR/no comp.?
3ENT for no radius compensationPrompt: Feed rate F=? / F MAX = ENT
4Type 100, ENT (just ENT for rapid traverse)Prompt: Miscellaneous function M?
5Type 3 (M3 spindle on clockwise)–
6Close the block with ENDThe block appears: 3 L X+10 Y+5 R0 F100 M3

Which keys are used during the dialog?

Key / soft keyWhat it does
ENTConfirms the entry and goes to the next question
NO ENTSkips the question (that word is not written)
ENDEnds the dialog immediately and saves the block
DELAborts the dialog and deletes the block

How do you capture the actual axis position in the program?

To move the tool to a point by hand and write that position into the program:

StepWhat to doWhat you see
1Move the input box to the word where the position should go–
2Press the actual position capture keyThe soft-key row shows the axes you can capture
3Select the axisThe current position of the axis is written into the input box

In the working plane the control always captures the tool center coordinates; in the tool axis it captures the tool tip, taking the active tool length into account. The function is not allowed while tilting the working plane is active.

How do you edit a program on a Heidenhain control?

Important: You cannot edit a program while it is being run in a machine operating mode. Stop the program or select another one.

Key / soft keyWhat it does
Up / down arrowGoes from block to block
Right / left arrowSelects individual words in a block
GOTOType a block number and press ENT to jump to it. Or type a number of lines and use the N LINES soft key to jump up/down
CESets the selected word to zero, clears a wrong value, clears a clearable error message
NO ENTDeletes the selected word
DELDeletes the selected block; deletes cycles and program sections
INSERT LAST NC BLOCKInserts the block you last edited or deleted

How do you change a value in a block?

StepWhat to doWhat you see
1Select the block with the arrow keys–
2Select the word to change with the right/left arrow (e.g. F100)The dialog prompt for that word appears
3Type the new valueIt overwrites the old value
4Press ENDThe change is applied to the block

To add a word to a block, press the right/left arrow until the dialog you want appears, then enter the value.

How do you insert a new block in the middle of a program?

Select the block after which the new block should go and start the dialog (e.g. the L key). The new block is inserted below the selected block.

How do you delete a block from a program?

StepWhat to doWhat you see
1Select the block to delete with the arrow keys–
2Press DELThe block is deleted
3If you deleted the wrong one: INSERT LAST NC BLOCK soft keyThe deleted block is inserted again

How do you save or undo changes?

The control normally saves changes automatically when you switch the operating mode or open the file manager. To save or undo deliberately, first switch to the soft-key row containing the saving functions.

ActionSoft keyResult
SaveSTOREAll changes since the last save are saved
Save asSAVE AS → (SWITCH for the folder if needed) → name → OK or ENTThe program is saved to a new file; it also appears under LAST FILES in the file manager
Undo changesCANCEL CHANGE → YES or ENTAll changes since the last save are undone; NO to abort

Tip: Before correcting a CAM program, use SAVE AS to keep a copy. If something goes wrong you still have the original.

How do you copy, cut or delete a section of a program?

Heidenhain TNC 640 soft keys for marking and copying program blocks
Marked blocks are shown in a different color; marking soft keys at the bottom.
StepWhat to doWhat you see
1Switch to the soft-key row with the marking functions–
2Select the first block of the section, SELECT BLOCK soft keyThe block is highlighted and CANCEL SELECTION appears
3Move the cursor to the last block of the sectionAll marked blocks are shown in a different color
4COPY BLOCK to copy, CUT OUT BLOCK to cut (delete)The section is stored in memory; with cut it is removed from the program
5Select the block after which the section should be inserted–
6INSERT BLOCK soft keyThe section is inserted
7Finish with CANCEL SELECTION–

To insert the section into another program, open that program from the file manager in step 5 and select the block there.

How do you search for and replace text in a program?

Heidenhain TNC 640 search and replace window
Search / Replace window and search soft keys.

How do you search for text?

StepWhat to doWhat you see
1Press the FIND soft keyThe search window opens
2Type the text, e.g. TOOL–
3Select forward or backward search–
4FIND soft keyJumps to the next block containing the text; FIND again for the next one
5End the search with the END soft key–

How do you replace a value throughout the program?

StepWhat to doWhat you see
1Select a block containing the word, FIND soft keyThe search window opens
2CURRENT WORD soft key (press again if needed)The word in the block is taken as the search text
3Enter the replacement text, FINDJumps to the next occurrence
4REPLACE: replace and go to the next · REPLACE ALL: replace all · FIND: skip without replacing–
5END soft key–

Caution: Text replaced with REPLACE ALL cannot be restored. Make sure you do not change text that should stay. Search and replace is not possible if the program is protected or currently being run.

How do you add a comment to a program?

Comments are the easiest way for operators to leave notes such as “check first part” in a program. A comment starts with the ; (semicolon) key on the alphabetic keyboard. The last character of a comment must not be ~.

Heidenhain TNC 640 adding a comment to a program
Comments are shown in green in the program.
WhenWhat to do
While entering a blockEnter the block data, press ;, type the comment at the Comment? prompt, END
Afterwards, on an existing blockSelect the block, go to the last word with the right arrow, ;, type the comment, END
As a separate blockSelect the block after which the comment goes, ;, type the comment, END

How do you temporarily disable a block by commenting it out?

Manuals for newer NC software (SW 08 and later) include a function to turn an existing block into a comment. Select the block and press the INSERT COMMENT soft key (or < on the alphabetic keyboard); a ; is added at the start of the block, then press END. To reverse it, select the block, press REMOVE COMMENT (or >) and END. If your software version does not have it, it cannot be used.

How do you delete a program file on a Heidenhain control?

Heidenhain TNC 640 file manager PGM MGT screen
PGM MGT: drives and directories on the left, files on the right.

Caution, data loss: A deleted file cannot be restored; the control does not back it up first (there is no recycle bin). Back up important programs regularly to a USB drive or the network.

StepWhat to doWhat you see
1Press PGM MGTThe file manager opens
2Select the directory on the left and the file on the right–
3Press the DELETE soft keyYou are asked whether to delete the file
4OK to confirm, CANCEL to abortThe file is deleted

A directory is deleted the same way; the control then asks whether to delete the directory with all its subdirectories and files.

How do you delete several programs at once?

StepWhat to doWhat you see
1Move to the first file, TAG soft keyThe tagging soft keys appear
2TAG FILE soft key; go to the next file and repeatThe files are tagged
3Leave the active soft-key row, DELETEThe tagged files are deleted (after confirmation)

How do you protect a program from accidental deletion?

StepWhat to doWhat you see
1Move to the file to protect–
2MORE FUNCTIONS soft key–
3PROTECT soft keyThe file is tagged with the protected symbol

To remove the protection, use the same path and press UNPROTECT. Search and replace is not possible in a protected program. To rename a file use the RENAME soft key; the file type (.H, .I) cannot be changed.

Frequently asked questions

Why can’t I edit the program that is running?

The control does not allow editing a program that is being run in a machine operating mode. Stop the program or select another program to edit.

How do you delete a block on a Heidenhain control?

In Programming, select the block with the arrow keys and press DEL. If you deleted the wrong block, the INSERT LAST NC BLOCK soft key inserts it again.

Can a deleted program be restored?

No. A file deleted with DELETE in the file manager cannot be restored. Back up important programs regularly and protect them with PROTECT if needed.

Can changes be undone?

Yes. CANCEL CHANGE in the saving soft-key row undoes all changes since the last save. Changes made with REPLACE ALL cannot be undone.

How do you jump to a block in a long CAM program?

Press GOTO, type the block number and confirm with ENT. To look for a word use the FIND soft key.

Heidenhain TNC 640 training series

Safety notice and disclaimer

Check every program you enter or correct by hand first graphically in Test Run, then on the machine in single block with a low feed override. Soft-key names and positions may differ with the NC software version and machine builder; the machine manual always takes priority.

Mentor CNC cannot be held responsible for tool breakage, scrapped parts, machine damage, data loss or accidents resulting from the use of the information on this page. Responsibility lies with the person and company carrying out the work.

Mentor CNC logo

MENTOR CNC
CNC knowledge from the shop floor

Mentor CNC turns hands-on shop-floor experience in CNC turning, CNC milling, CNC controls, cutting tools and engineering calculations into clear, practical technical content.

Our goal is to help operators, students, engineers and shop owners reach accurate information faster and make safer, more efficient decisions in production.