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
 
(3 intermediate revisions by the same user not shown)
Line 21: Line 21:
Display a File Open dialog:this is used to select an Existing file.  
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.
'''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 <q>file description</q> followed by <q>file extension</q> separated by <q>|</q>. The filter list is terminated by <q>||</q> . As shown: "Toolpaths (*.tap) | *.tap||".''
 
 
 
 
 


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 <q>file description</q> followed by <q>file extension</q> separated by <q>|</q>. The filter list is terminated by <q>||</q> . As shown: "Toolpaths (*.tap) | *.tap||".''




Line 42: Line 34:
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.  
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.
'''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.''
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.''
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 <q>file description</q> followed by <q>file extension</q> separated by <q>|</q>. The filter list is terminated by <q>||</q> . For Example: Toolpaths (*.tap) | *.tap||".
filter (string)filter string to display for dialog file type.The string is build up of pairs of <q>file description</q> followed by <q>file extension</q> separated by <q>|</q>. The filter list is terminated by <q>||</q> . For Example: Toolpaths (*.tap) | *.tap||".
Line 65: Line 57:
'''Interaction:''' Read and Write
'''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()
'''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()




Line 71: Line 63:
'''Interaction:''' Read Only
'''Interaction:''' Read Only


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




Line 79: Line 71:
'''Interaction:''' Read Only
'''Interaction:''' Read Only


'''Returns:''' (string) extension of the file chosen
'''Returns:''' (string) extension of the file chosen




Line 87: Line 79:
'''Interaction:''' Read Only
'''Interaction:''' Read Only


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




Line 95: Line 87:
'''Interaction:''' Read Only
'''Interaction:''' Read Only


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




Line 103: Line 95:
'''Interaction:''' Read Only
'''Interaction:''' Read Only


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




Line 110: Line 102:
'''Interaction:''' Read Only
'''Interaction:''' Read Only


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




Line 116: Line 108:
[[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]

Latest revision as of 17:48, 1 May 2024

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