This chapter continues with the existing standard configuration. We use Program → File Management to select an existing NC program, then follow the screen and scripts: where the directory comes from, what a single click records, and what changes when Selection is pressed. No buttons or replacement file manager are added.
Click the screenshot to view the original image.
Figure 1. Click File Management under Program. The example directory, programs-en, contains circular-pocket.nc. The Filter: field shows *.nc *.txt *.tap *.cnc. The top-right status reads Simulation.
Identify these areas first:
| Screen area | What to look for |
|---|---|
| Drive letter on the left | The drive to browse |
| Central file table | Name, Size, Type, and Date modified; rows may be files or directories |
| Bookmark below the file table | Frequently used directories, rather than the machining list |
| File path: at the bottom | The directory being browsed |
| File name: at the bottom | The name most recently clicked |
| Filter: at the bottom | File types to list |
| Selection at the bottom right | Pass the selected table rows to the machining list |
Click circular-pocket.nc once. Do not press Selection yet.
Click the screenshot to view the original image.
Figure 2. This capture shows the native file-management area. File name: now contains circular-pocket.nc, while the table still shows the directory. This step records the clicked file. In this example, the current machining file is still empty.
Now press Selection. The page returns to Toolpath Preview, and the program text appears:
Click the screenshot to view the original image.
Figure 3. Only the file title and program text area are captured here. The first line is G90G0Z20.000; the second is M3S12000. These are file contents. Displaying them does not execute the spindle or axis commands.
A row also appears in the machining list:
Click the screenshot to view the original image.
Figure 4. This example starts with an empty machining group. It shows Starting Line 0, End line -1, zero offsets and rotation, Quantity 0/1, and Status Ready. These are the actual example values. They do not mean that selecting another program always clears previous offsets.
The screenshots show the standard interface. Coordinates, filenames, and parameter values are examples; use the values appropriate to your configuration.
Paths below are relative to the software's runtime directory.
| File | Its part in this example |
|---|---|
env/maininterface/maininterface.ui |
File Management entry, subpage area, program text area, and machining list |
env/file/filepage |
Read the directory and load the file page on first entry |
env/file/file.ui |
File table, path field, filter field, and buttons |
env/file/enterDir |
Enter a clicked directory, or record a clicked filename |
env/file/selectFile |
Read selected rows, fill the machining list, and return to Toolpath Preview |
env/file/setDir, filter |
Read the directory again after a path or filter is submitted |
env/file/selectAllFile |
Select all files currently listed for the directory |
Each set of data has a separate purpose:
| Parameter | Purpose here | Do not confuse it with |
|---|---|---|
#802 |
Current directory and its file records | Current machining file |
#802.description |
Most recently clicked filename | All selected rows, or a full path |
#6.item[...] |
Temporary selected row numbers received by Selection | Permanent customer settings |
#334 |
Machining list: one group per machining file and its settings | Disk directory listing |
#403 |
Current machining file path | Every file shown on the page |
#9047 |
File path for the program text area | Necessarily the file currently being machined |
#810 |
Which Program subpage is visible | File validity or a machining start command |
Follow the example in this order: directory → file table → selected row numbers → full paths → machining list and text display.
The existing File Management entry has this event:
-A:(clickedEvent:/env/file/filepage[0](#810=1))
It sets #810 to 1, then calls filepage. The complete script is:
widgetFunc["disk","","",803]
IF#811.version==1GOTO1
#811.version=1
widgetFunc["dir",#802,"",802]
#811.itemdesc[0]="/env/file/file.ui"
widgetFunc["QFrame","fileFrame","refresh",""]
N1
Read it in order:
disk obtains the drives and puts them in #803 for the drive table on the left.#811.version records whether this page has already been loaded in the current session. A value of 1 skips to the end.1, then use dir to read the directory specified by #802.file.ui path in #811.itemdesc[0].fileFrame in the main screen to load the file page there.Pay particular attention to this line:
widgetFunc["dir",#802,"",802]
The second argument, #802, supplies the directory string. The fourth argument, 802, is the parameter number that receives the records. The same parameter stores both the directory and its entries. Replacing the fourth argument with #802 changes its meaning.
For each record, dir fills these fields:
| Field | Contents for the file row in Figure 2 |
|---|---|
#802.item[i] |
Filename circular-pocket.nc |
#802.itemtitle[i] |
Full path, including drive, directory, and filename |
#802.itemversion[i] |
0 for a file; 1 for a directory |
#802.itemmax[i] |
File size: 4662 bytes in this example |
#802.itemunit[i] |
Extension: nc here |
#802.itemdesc[i] |
Modification time obtained when the directory was read |
Here, .itemmax stores file size and .itemunit stores an extension. Their meanings differ from the upper limit and unit used by a parameter input page.
The file table is named filebrows. Its row definition is -rows:#802itemnum: one row per directory record. In this example, row 0 is .., and row 1 is the NC file. A script must not assume that row 0 is always a file.
When #802.title equals the path being read, dir omits ... This controls the parent-directory row; it does not restrict users to that directory.
During initialization, env/main clears #811.version and the previous subpage path, allowing the page to load again in a new session. file-install installs parameters; it is not part of this page-entry call sequence.
The file table's first column has this click event:
-A: (clickedEvent:/env/file/enterDir[0](#2=%%))
Here, %% supplies the current table row number. Figure 2 uses row 1, so the event prepares #2=1 and runs this complete script:
IF#802.itemversion[#2]==0GOTO1
widgetFunc["dir",#802.itemtitle[#2],"",802]
#802.description=""
GOTO2
N1
#802.description=#802.item[#2]
N2
For a directory, it reads that directory and clears the filename field. For a file, it jumps to N1 and writes the name to #802.description.
The File name: input is bound to -T(#802description), so the new name appears there. These lines do not fill #334 or change #403 or #9047. Figure 2 shows the most recently clicked name.
Typing a name directly into File name: also does not select a table row. Selection reads the table's selected rows; that input alone does not establish which rows are selected.
The original filename cell also calls selectFile on a double-click. This chapter uses “click the file, then press Selection” to explain the two steps. Directory double-clicks and touch-event ordering still require verification in the complete application.
The Selection button is named pushButton_4. Its click event calls /env/file/selectFile[0]. The script below preserves the original numbers and syntax:
IF[#319.item[3]==1]+[#319.item[7]==1]GOTO2
widgetFunc["QTableWidget","filebrows","getSelectedIndex",6]
IF#6.itemnum==0GOTO1
#334.groupnum=#6.itemnum
#500=0
WHILE#500<#6.itemnumDO1
#334.item[20*#500]=1
#334.item[20*#500+1]=#802.itemtitle[#6.item[#500]]
#334.item[20*#500+2]=0
#500=#500+1
END1
#403=#334.item[1]
#9047=#334.item[1]
#324.item[2]="00:00:00.000"
#9048.channel=0
#9048.permission=widgetFunc["getFileLineNum","","",#403]
#331.item[2]=1
#810=0
#333.item[1]=0
#333.item[13]=1
#904=FIX[[#904.itemnum-1]/10]
#904.item[#904.itemnum-1]=#324
#904.itemdesc[#904.itemnum-1]=#1107.itemtitle[11]+#403
#904.itemversion[#904.itemnum-1]=0
#904.itemnum=#904.itemnum+1
GOTO1
N2
widgetFunc["messageBox",#1107.itemtitle[27],#1107.itemtitle[28],""]
N1
Read it as five parts:
| Part | Purpose | Result in this example |
|---|---|---|
| First-line status check | Show a message instead of changing files in the specified interpreter busy states | The example is idle, so processing continues |
getSelectedIndex |
Obtain selected rows from filebrows in the current form and put them in temporary parameter #6 |
#6.itemnum=1; #6.item[0]=1 |
WHILE loop |
Fill one machining group for each selected row | The first group receives the NC file's full path |
#403 through #333 |
Update current/display files, line position, time, counts, and subpage | Return to Toolpath Preview and show the program |
Final #904 lines |
Append a file-selection log entry | Record the selected path |
Here, #333.item[1] is the completed count and #333.item[13] is the loop count. Selection sets them to 0 and 1, producing 0/1 in Figure 4. The latter is not a preview-generation flag. #9048.permission stores the file's line count here; its field name does not make it an account-permission setting.
With no selected rows, IF#6.itemnum==0GOTO1 exits the script. The local check confirmed that the machining list and current file remain unchanged in that case.
The selected-row function looks for filebrows in the form used by the current script. Copying that line into another window requires a corresponding table in that window.
In this version, #334 stores machining groups. Each group expands to 20 fields, so group g begins at 20*g:
| Setting | First group, number 0 |
Second group, number 1 |
|---|---|---|
| Include in machining | #334.item[0] |
#334.item[20] |
| Full file path | #334.item[1] |
#334.item[21] |
| Starting line | #334.item[2] |
#334.item[22] |
| End line | #334.item[3] |
#334.item[23] |
| X offset | #334.item[4] |
#334.item[24] |
Only one row is selected here, so #500=0 in the loop. The filename assignment reads #802.itemtitle[#6.item[0]], which is #802.itemtitle[1], and writes it to #334.item[1].
These are two different uses of 1: the file-table row number and the file-path field in the first machining group. They happen to match. If row 4 is selected instead, the first machining group's path still goes into #334.item[1].
The file table supports multiple selection. Each selected row goes through the loop. Check the resulting order in the machining list; do not assume it is guaranteed to follow the order of mouse clicks.
When files are selected again, the standard script explicitly writes only fields 0, 1, and 2 of each group. Existing groups may retain their end line, offsets, and rotation settings. Figure 4 shows defaults from this example's empty group; the selection script did not explicitly clear all those settings.
Select All uses selectAllFile. It walks the current directory records and selects files by their file/directory flag. It does not depend on highlighted rows and does not recursively read subdirectories. This example directory contains one file, so the local check again produced one machining group.
The ordinary Selection script does not separately reject directory rows. Check that the selected entries are files. A future custom selection entry should explicitly decide whether to add a directory check; this chapter leaves the original feature unchanged.
The script writes these two lines together:
#403=#334.item[1]
#9047=#334.item[1]
The first sets the current machining file. The second sets the file for the program text area. At this point, both use the same path.
The main UI defines the program text area as follows:
-T(#9047<<#9048.channel) -D
-C(#319.item3==1||#319.item7==1)
-R0
#9047 supplies the file; #9048.channel supplies the display line position. -D includes the control in UI updates, and the condition makes it read-only in the specified busy states. When loading the UI, the software creates the actual program editor at this position. Follow the binding; the class name stored in the .ui does not require you to write another file reader.
The software compares the file path, modification time, and size, then reloads text when one changes. File size must also be less than #9980.item[6]*1000 bytes. The text area may be empty if the file cannot be opened or fails that size condition. getFileLineNum counts file lines; it does not validate G code. It returned 324 for this file. Failure or reaching the size limit can return -1.
#331.item[2]=1 requests that the old toolpath be cleared. Clearing a toolpath and displaying new text do not command the NC interpreter to regenerate the complete toolpath. Standard selectFile does not write the machining start flag.
Click the screenshot to view the original image.
Figure 5. To relate the program to its geometry, this image uses the original NC interpretation and drawing code separately after file selection. The text and machining list still refer to circular-pocket.nc. It is not evidence that pressing Selection immediately generates a toolpath, or a completed test of the release application's simulation button. No machine scheduler was started. Simulation and start operation will be explained in the machining chapter.
There is another common operation: clicking a different row in an existing machining list. That uses env/funcscripts/selfilelist to update #9047 and other display data. The script does not also assign #403. Keep “the program being viewed” separate from “the current machining file.”
The two original inputs have these bindings:
-T(#802)
-D
-A: (Return:/env/file/setDir[1])
-T(#802unit)
-D
-A: (Return:/env/file/filter[1])
The first is File path:; the second is Filter:. Pressing Enter first writes the input back to the bound field, then runs the Return script. The complete setDir script is:
#802.description=""
widgetFunc["dir",#802,"",802]
The complete filter script is just:
widgetFunc["dir",#802,"",802]
These inputs illustrate an existing design method: the input transfers the user's text to a parameter; a short script performs the next operation. Each input does not need its own directory-reading implementation.
Separate multiple patterns with spaces, such as *.nc *.tap. The pictured *.nc *.txt *.tap *.cnc contains four patterns. They filter filenames. Directories remain listed, and file contents are not checked for machining validity.
The original input events were checked locally: submitting *.nc kept the NC file in the table and retained the most recently clicked name. Submitting the current directory again kept the file listing but cleared File name:. This matches the presence or absence of the clearing line in the two scripts.
Returning to File Management alone skips directory reading because filepage sees #811.version==1. If an externally generated file does not appear, submit the path or filter again. Switching away and back does not guarantee a refreshed listing.
With the main sequence understood, identify the surrounding features:
| Operation | Script and data | Keep this distinction |
|---|---|---|
| Choose a drive | selectDir, using a path from #803.itemtitle[...] |
Changes the browsing directory, without directly selecting a machining file |
| Add to Bookmarks | addSticky, appending the directory to #804.itemtitle[...] |
Stores a directory, not an individual NC file |
| Click a bookmark | stickyDir, reading that directory |
The path must still exist on the current computer |
| Double-click a bookmark | delSticky, removing the bookmark entry |
Removes a record, not a disk directory |
| Browse | browseFile, using the external program specified by #418 |
Separate from Selection; its multiple-file argument construction needs further checking |
| Copy, Paste, Delete | copy, paste, delete |
Disk file operations, rather than machining-list editing |
This chapter did not execute external browsing, copying, pasting, or deletion, or test bookmark persistence across a restart. The scripts and limitations are described in the file-operation reference, currently in Chinese.
The bottom F1 Load File key is another entry. It uses env/funcscripts/selectfile to open a native file dialog. That script also has a reverse-processing and simulation-start branch controlled by #929.item[4]. Similar names do not make it identical to the file page's selectFile. Follow the path assigned to the actual button.
If a customer asks to open a particular directory by default, show certain file types, or load an externally generated program, first identify the step to change:
| Requested change | Look here first |
|---|---|
| Which directory to browse | #802 and the directory-reading entry |
| Which file types to list | #802.unit, and whether dir runs after the change |
| What the table displays | filebrows in file.ui, and its correspondence with #802 records |
| Which rows may enter the machining list | Selected-row reading and the selectFile loop; required directory, range, and file-existence checks |
| Which program to show after selection | #334, #403, #9047, and line-position updates |
| Whether to regenerate a toolpath or start machining | The separate simulation/start sequence; displayed text alone does not establish this |
If table rows are filtered, independently sorted, or paged, recheck visible row number → #802 record number. Direct use of the row number works in the standard table because each row corresponds to one directory record.
Use these checks for common problems:
| Symptom | Check first |
|---|---|
| A filename is visible, but Selection does not change the program | Whether a table row is selected; File name does not replace the selected-row set |
| The old listing remains after changing directories | Whether dir succeeded; a missing directory returns -1 before clearing old records |
| A generated file is absent after returning to the page | Whether the directory was actually read again |
| Previous offsets or end line remain after selection | Whether the existing group was reused; the selection script does not clear those settings individually |
| The filename is correct but the text area is empty | The file specified by #9047, read access, and the size limit |
| Text appears but no new toolpath is drawn | Whether only selection has completed, without the required interpretation and drawing |
| Multiple selection processes the wrong files | Whether the last clicked name replaced the selected-row set, or row-to-record correspondence changed |
This chapter explains the existing selection sequence without adding customer-specific directories, buttons, or installation scripts. The next chapter will examine Teach: how the existing pages organize user actions and parameters into an NC program.
Previous: Coordinate input · Next: Start, pause, resume and stop · Reading guide