Here's a function to get the contents of a file:
function getFileContents(%path) {
%file = new FileObject();
%file.openForRead(%path);
while( !%file.isEOF() ) {
%line = %file.readLine();
%contents = (%contents $= "" ? %line : %contents @ "\n" @ %line);
}
%file.close(); %file.delete();
return %contents;
}
To display it in a GUI:
function [MyGuiMLTextCtrl]::loadFile(%this, %path) {
%this.setText( getFileContents(%path) );
}
To save text to a file:
function setFileContents(%path, %data) {
%file = new FileObject();
%file.openForWrite(%path);
while( (%next = strstr(%data, "\n")) >= 0 ) { // Split the data into lines
%datum = getSubStr(%data, 0, %next);
%data = getSubStr(%data, %next + 1, strlen(%data));
%file.writeLine(%datum);
}
%file.close(); %file.delete();
}
To save from a GUI:
function [MyGuiMLTextCtrl]::saveToFile(%this, %path) {
setFileContents(%path, %this.getText());
}
All of that would go together and you'd have to make a GUI with a textbox (GuiMlTextCtrl) that has a name (replace the "[MyGuiMLTextCtrl]" in the code with the name of your text box). Then you can make buttons that use saveToFile() and loadFile() methods, getting the filepath from a GuiTextEditCtrl.