Luart
Comprehensive Windows framework to develop in Lua
modules > ui > savedialog

ui.savedialog ([title] , [allow_mutiple_selection] , [filters])

Displays a dialog box for the user to specify the drive, directory, and name of a file to save.

Parameters

title

An optional string that indicates the title of the dialog box (use the default system title if not specified).

allow_multiple_selection

An optional boolean value that indicates if the dialog allow multiple files selection or not.

filters

An 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 and a field, each separated by the character "|". For example, the string "All files (*.*)|*.*|Text files (*.txt)|*.txt" defines 2 filters :
  • 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 value

This function returns the selected file(s) as File object(s) or nil if no files have been choosen.

Example


local ui = require "ui"

-- open a dialog to choose a file to be saved
local file = ui.savedialog("Save current date to...")

-- checks if a file has been selected
if file ~= nil then
	-- open the file and write the current date & time to it
	file:open("write"):write(sys.Datetime())
end