ui.opendialog ([title] , [allow_mutiple_selection] , [filters])Displays a dialog box for the user to choose a file or set of files to be opened. The file(s) must exist physically on the drive.
titleAn optional string that indicates the title of the dialog box (use the default system title if not specified).
allow_multiple_selectionAn optional boolean value that indicates if the dialog allow multiple files selection or not.
filtersAn optional string that indicates filters. A filter is used to display only files with a specified pattern. If omitted, the dialog shows all files.
A filter is composed of a
- A filter named "All files (*.*)" that correspond to the search pattern "*.*"
- A filter named "Text files (*.txt)" that correspond to the search pattern "*.txt"
Return valueThe function returns the selected file(s) as File object(s) or nil if no files have been choosen.
local ui = require "ui" -- open a dialog to choose an existing file local file = ui.opendialog() -- checks if a file has been selected if file ~= nil then ui.info("File path : "..file.fullpath.."\nFile size : "..file.size.." bytes\nFile creation date : "..file.created.."\n") end