From 0ab4a35ec9d4f009bf481a81c865afd0fb032a10 Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Thu, 23 Dec 2010 02:03:13 -0500 Subject: [PATCH] Extensions: OpenScriptEx, Open a new script from filename. --- Projects/Simba/psextension.pas | 1 + Units/MMLAddon/PSInc/Wrappers/extensions.inc | 36 +++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Projects/Simba/psextension.pas b/Projects/Simba/psextension.pas index 17f3aaa..d09a6dd 100644 --- a/Projects/Simba/psextension.pas +++ b/Projects/Simba/psextension.pas @@ -193,6 +193,7 @@ begin AddFunction(@ext_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;'); AddFunction(@ext_ScriptText,'function ScriptText: string;'); AddFunction(@ext_OpenScript,'procedure OpenScript(Name, Data: string);'); + AddFunction(@ext_OpenScriptEx,'procedure OpenScriptEx(FileName: string);'); AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox'); AddFunction(@ext_GetPageEx,'function GetPageEx(const URL, PostData, MimeType: string): string;'); AddFunction(@ext_GetJSONValue,'function GetJSONValue(const Data, Value: string): string;'); diff --git a/Units/MMLAddon/PSInc/Wrappers/extensions.inc b/Units/MMLAddon/PSInc/Wrappers/extensions.inc index 56599d6..ab1ba48 100644 --- a/Units/MMLAddon/PSInc/Wrappers/extensions.inc +++ b/Units/MMLAddon/PSInc/Wrappers/extensions.inc @@ -133,11 +133,37 @@ procedure ext_OpenScript(Name, Data: string); begin if (Name = '') then Name := 'Untitled'; - SimbaForm.AddTab; - SimbaForm.CurrScript.SynEdit.Lines.Text := Data; - SimbaForm.CurrScript.ScriptName := Name; - SimbaForm.RefreshTab; - SimbaForm.UpdateTitle; + + with SimbaForm do + begin + AddTab(); + with CurrScript do + begin + SynEdit.Lines.Text := Data; + ScriptName := Name; + end; + RefreshTab(); + UpdateTitle(); + end; +end; + +procedure ext_OpenScriptEx(FileName: string); +begin + FileName := SetDirSeparators(FileName); + with SimbaForm do + begin + AddTab(); + with CurrScript do + begin + SynEdit.Lines.LoadFromFile(FileName); + StartText := SynEdit.Lines.Text; + ScriptName := ExtractFileNameOnly(FileName); + ScriptFile := FileName; + ScriptChanged := False; + end; + RefreshTab(); + UpdateTitle(); + end; end; function ext_GetPageEx(const URL, PostData, MimeType: string): string;