FileDialog: Difference between revisions

From SDK
Jump to navigation Jump to search
(Created page with "right|50px|link=User Interface Category:SDK This object is used to display either a File Open or a File Save dialog box to the user. ==Constructor==...")
 
No edit summary
Line 116: Line 116:
[[File:Back.jpg|right|50px|link=User Interface]]
[[File:Back.jpg|right|50px|link=User Interface]]
==References==
==References==
'''Please Note:''' The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information]
'''Please Note:''' The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 10.0, published August 21, 2019. by Vectric Ltd. Most current document from Vertric can be downloaded at [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information]

Revision as of 08:20, 4 August 2021

Back.jpg

This object is used to display either a File Open or a File Save dialog box to the user.


Constructor

FileDialog()

Create a new object used for displaying a File Open or Save dialog

 local file_dialog = FileDialog() 


Methods

:FileOpen(string default_ext,string file_name, string filter)

Display a File Open dialog:this is used to select an Existing file.

Returns: (bool) true if user selects a file else false if they cancel the dialog.

default_ext (string) The default filename extension. If the user does not include an extension in the Filename edit box, the extension specified here is automatically appended to the filename. If this parameter is empty (""), no file extension is appended.
file_name (string)path to default file to open. Can just be path or include filename or just be left empty (""), usually use "*.ext" at end of string to preselect all files of a particular extension.
filter (string)filter string to display for dialog file type.The string is build up of pairs of file description followed by file extension separated by |. The filter list is terminated by || . As shown: "Toolpaths (*.tap) | *.tap||".






:FileSave(string default_ext,string file_name, string filter)

Display a File Save dialog:this is usually used to select a new file for saving to but user can choose to overwite an existing file.

Returns: (bool) true if user selects a file else false if they cancel the dialog.

default_ext (string) The default filename extension. If the user does not include an extension in the Filename edit box, the extension specified here is automatically appended to the filename. If this parameter is empty (""), no file extension is appended.
file_name (string)path to default file to open. Can just be path or include filename or just be left empty (""), usually use "*.ext" at end of string to preselect all files of a particular extension.

filter (string)filter string to display for dialog file type.The string is build up of pairs of file description followed by file extension separated by |. The filter list is terminated by || . For Example: Toolpaths (*.tap) | *.tap||".

Example Code:

local file_dialog = FileDialog()
if not file_dialog:FileSave("tap", "d:\\Temp\\*.tap", "Toolpaths (*.tap)|*.tap|") then
  MessageBox("No file to save to selected")
  return false
end

MessageBox("User chose file:\n"   file_dialog.PathName)

Properties

.InitialDirectory

Interaction: Read and Write

Returns: (string) folder or directory the dialog should display when first opened the properties below are used to access the data on the file chosen and are only valid after the dialog has returned from:FileOpen() or FileSave()


.Directory

Interaction: Read Only

Returns: (string) directory or folder (and drive) of the file the user chose (same as .Folder)



.FileExt

Interaction: Read Only

Returns: (string) extension of the file chosen



.FileName

Interaction: Read Only

Returns: (string) filename without the path but including the extension



.FileTitle

Interaction: Read Only

Returns: (string) name of file without path or extension



.PathName

Interaction: Read Only

Returns: (string) The full pathname to the file the user


.Folder

Interaction: Read Only

Returns: (string) folder or directory (and drive) of the file the user chose (same as .Directory)


Back.jpg

References

Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 10.0, published August 21, 2019. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information