Hi,
Does anyone know if it is possible to read a local text file chosen with the filerequester and populate a listview with its contents?
Regards
Andy
Read a local text file
Re: Read a local text file
this one works for me (Chrome, IE, Ff):
Greetings ... Peter
Code: Select all
EnableExplicit
Enumeration
#myWindow
#myButton
#myEditor
EndEnumeration
Global EditorGadgetID
! $('<div style="width:0px;height:0px;overflow:hidden"><input name="upload" type="file" id="fileinput"/></div>').appendTo($('body'));
! document.getElementById('fileinput').addEventListener('change', readTextFile, false);
! function readTextFile(e) {
! var file = e.target.files[0];
! if (!file) return;
! var reader = new FileReader();
! reader.onload = function(e) {
! v_editorgadgetid.SetGadgetText(e.target.result);
! };
! reader.readAsText(file);
! }
Procedure myButtonEvent()
! $('#fileinput').trigger('click');
EndProcedure
OpenWindow(#myWindow, 100, 100, 400, 400, "")
ButtonGadget(#myButton, 10, 10, 200, 30, "Open local textfile...")
EditorGadget(#myEditor, 10, 50, WindowWidth(#myWindow) - 20, WindowHeight(#myWindow) - 60)
EditorGadgetID = GadgetID(#myEditor)
BindGadgetEvent(#myButton, @myButtonEvent())
Re: Read a local text file
I will try to add the file library for the next version to be able to do it natively.