Command: FileNameGet
- Updated2024-09-12
- 10 minute(s) read
Command: FileNameGet
Command: FileNameGet
Opens the standard dialog box for loading and saving files.
Input Parameters
FileTargetDevice |
Specifies the DIAdem panel for which you load or save a file. |
FileOperation |
Specifies whether you load a file or save a file. |
[FileDlgName] |
Specifies a file. You can also specify the path and the filename extension. |
[FileDlgFilt] |
Specifies the file type. |
[FileDlgASCIIName] |
Specifies the ASCII file where you save the names of the files that you selected in the dialog box for opening and saving files. |
[FileDlgPathKey] |
Specifies whether DIAdem stores the names of the selected files with absolute paths or without paths in the ASCII file. The default value is FALSE which specifies that DIAdem does not save the absolute path as well. |
[FileDlgCaption] |
Specifies the dialog box caption. |
Return Parameters
ReturnValue |
Receives the status of a dialog box after you exit the dialog box. The return value is a DlgState type. |
| Receives the action you selected in the dialog box. | |
| Receives the path of the file that you selected in the dialog box for loading and saving. If you use the FileNameGet command to open a file selection dialog box and select several files, the FileDlgDir variable receives the path of the last file selected in the file selection dialog box. | |
| Receives the name of the file that you selected in the dialog box for loading and saving. If you use the FileNameGet command to open a file selection dialog box and select several files, the FileDlgFile variable receives the name of the last file selected in the file selection dialog box. | |
| Receives the name of the files that you selected in the dialog box for loading and saving. If you use the FileNameGet command to open a file selection dialog box and select several files, the FileDlgFileName variable receives the filenames separated by a vertical line, for example: If you select only a file, DIAdem always saves the complete path regardless off the FileDlgPathKey variable. | |
| Receives the filename extension of the file that you selected in the dialog box for loading and saving. If you use the FileNameGet command to open a file selection dialog box and select several files, the FileDlgDir variable receives the filename extension of the last file selected in the file selection dialog box. If you call the command FileNameGet with the parameter ANY, and if you have selected the checkbox Hide extensions for known file types in the Windows Explorer, the FileDlgExt variable receives an empty string. | |
| Specifies whether to save only specified data or all data. The FileDlgPartial variable receives the value TRUE if you click Selective loading to close the dialog box for loading files, or if you select Only elements selected in the Data Portal. Otherwise, the variable is FALSE. | |
| Receives the data type when DIAdem loads and saves data. |
| Note You only can use the variables FileDlgName and FileDlgFilt if you assign the value ANY or NAVIGATOR to the FileTargetDevice variable. You also can use the variables FileDlgASCIIName and FileDlgPathKey if you assign the value ANY to the FileTargetDevice variable. |
| Note DIAdem does not check whether the specified file matches the set filter. If you assign the value NAVIGATOR to the FileTargetDevice variable, DIAdem interprets the variables FileDlgFilt and FileDlgFilter as names of the associated DataPlugins. |
Examples
Selecting several files for any follow-up actions:
In the following example, DIAdem opens the dialog box for loading and saving files. The dialog box title is Data selection. DIAdem writes the file names, with absolute paths, that you select in this dialog box to the All.lst file in the SCRIPT user folder. DIAdem also saves the filenames in the FileDlgFileName variable. Use the Split function to obtain the filenames.
| VBScript | Python |
Dim MyFileNames, iCount Call FileNameGet("ANY", "FileRead", DataReadPath, "TDM data (*.tdm),*.tdm", "All.lst", True, "Data selection") MyFileNames = Split(FileDlgFileName,"|") For iCount = 0 To Ubound(MyFileNames) Call DataFileLoad(MyFileNames(iCount)) Next
Selecting a file for easy loading:
In the following example DIAdem loads a layout in the DIAdem REPORT panel. You select the filename in the dialog box of the FileNameGet command.
| VBScript | Python |
If (FileNameGet( "REPORT", "FileRead", LayoutReadPath & ".TDR") = "IDOk") Then ' Dialog closed with Ok Call Report.LoadLayout(FileDlgFileName) Call Report.Refresh() End If
Selecting a file for user-defined loading:
In the following example DIAdem loads data in the DIAdem NAVIGATOR panel. You select the filename in the dialog box of the FileNameGet command. The example checks whether DIAdem loads the data completely or selectively.
| VBScript | Python |
If (FileNameGet("NAVIGATOR", "FileRead", DataReadPath & ".TDM") = "IDOk") Then ' Dialog closed with Ok If FileDlgPartial Then ' Open dialog to select channels, then load or register Call DataFileSelDlg(FileDlgFileName,FileDlgFilter) Else ' Load or register all channels Call DataFileLoad(FileDlgFileName,FileDlgFilter,FileDlgImpAction) End If End If
Selecting a file for easy storage:
In the following example DIAdem saves a layout in the DIAdem REPORT panel. You select the filename in the dialog box of the FileNameGet command. DIAdem overwrites existing files without a request for confirmation.
| VBScript | Python |
If (FileNameGet("REPORT", "FileWrite", LayoutReadPath & "*.TDR") = "IDOk") Then ' Dialog closed with Ok Call Report.SaveLayout(FileDlgFileName) End If
Selecting a file for user-defined storage:
In the following example DIAdem saves data in the DIAdem NAVIGATOR panel. You select the filename in the dialog box of the FileNameGet command. DIAdem checks whether the selected file exists and whether to overwrite the file. DIAdem also checks whether to save the data selectively.
| VBScript | Python |
If (FileNameGet ("NAVIGATOR", "FileWrite", DataReadPath & Data.Root.Properties("name").Value & "." & DataExtension) = "IDOk") Then If FilEx(FileDlgFileName) Then 'File exists Call MsgBoxDisp("File " & FileDlgFileName & " exists. Overwrite?","MB_YESNO") If (MsgState = "IDYes") Then If (FileDlgPartial= TRUE) Then 'Use selected channels Call DataFileSaveSel(FileDlgFileName, FileDlgFilter, Portal.ActiveView.Selection) Else Call DataFileSave(FileDlgFileName, FileDlgFilter ) End If Else 'Dialog was canceled Call MsgBoxDisp ("Data saving was canceled") End If Else 'File does not exist If (FileDlgPartial= TRUE) Then 'Use selected channels Call DataFileSaveSel(FileDlgFileName, FileDlgFilter, Portal.ActiveView.Selection) Else Call DataFileSave(FileDlgFileName, FileDlgFilter ) End If End If Else 'Dialog was canceled Call MsgBoxDisp ("Data saving was canceled") End If
Related Topics
Command: ChnValExpand | Command: DataFileLoad | Command: DataFileLoadRed | Command: DataFileLoadSel | Command: DataFileSave | Command: DataFileSaveSel | Command: DataFileSelDlg | Command: FileDlgShow | Command: PathDlgShow | Commands and Variables for Working with Data | Variable: FileExportFilter | Variable: FileFilter | Variable: FileImportFilter

