FileDialog: Difference between revisions

From SDK
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 28: Line 28:


  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||".''
  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 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)





Latest revision as of 18: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