Byte Order Mark (BOM) is used to dectect file encoding automatically.
Edit:load(file | filename, [ isrichtext ]) method
Loads the Edit content from the specified file.
Parameters
File | filename
A File object or a filename string, representing the file whose content will fill the Edit.
[ isrichtext ]
An optional boolean value indicating wether the file content is in RichText format, or not. If omitted, this parameter defaults to the Edit.richtext property value.
Return value
This function returns true if it succeeds or false if it fails.
Example
local ui = require "ui"
-- create a simple window
local win = ui.Window("Edit.load sample", "fixed", 520, 460)
local button = ui.Button(win, "Open a file",210, 10)
local edit = ui.Edit(win, "", 10, 44, 500, 410)
-- set edit.properties
edit.font = "Courier New"
edit.fontsize = 8
edit.wordwrap = true
function button:onClick()
local file = ui.opendialog()
if file ~= nil then
edit:load(file)
end
end
win:show()
-- update user interface
repeat
ui.update()
until not win.visible