Date: 20/12/2006
| Well after a fair bit of hacking and QA I've got the script engine in Scribe running some non-trivial scripts. In test11 you'll be able to create scripts and have them hang off the tools menu of the main window. Just put a ".script" file in "./Scripts" under Scribe.exe and it'll get inserted in the Tools menu. Inside the script you need to define a "Main" function in LGI script (see i.Mage's help for documentation) which will get run when you select the menu item that corrasponds to the script.
I'm initially converting the existing bottom 3 "utility" style commands on Tools menu to script to test the system. So far the first one looks like this:
//
// Deletes all the attachments in the current folder after asking the user.
//
// MenuText = Delete all attachments in current folder
// MenuStrRef = 1266
//
function Main(App)
{
Folder = App.CurrentFolder;
Print("Folder='" + Folder.Path + "'\n");
if (Folder)
{
if (Folder.Type == 0xAAFF0001)
{
Load(Folder);
Bytes = 0;
Count = 0;
Len = Folder.Length;
for (i=0; i<Len; i++)
{
t = Folder.Item[i];
if (t)
{
Attachments = t.Attachments;
for (n=0; n<Attachments; n++)
{
a = t.Attachment[n];
if (a)
{
Bytes += a.Length;
Count++;
}
}
}
}
if (MsgBox( App,
"Do you want to delete " + Bytes + " bytes in " + Count + " attachments?",
Name,
4) == 6)
{
for (i=0; i<Len; i++)
{
t = Folder.Item[i];
if (t)
{
Attachments = t.Attachments;
for (n=0; n<Attachments; n++)
{
a = t.Attachment[n];
Delete(a);
}
}
}
}
}
else
{
MsgBox(App, "Folder doesn't contain mail.", "Delete Attachments");
}
}
else
{
MsgBox(App, "No current folder?", "Delete Attachments");
}
}
And that works fine. It's a little rough around the edges but it works as advertised. I had to fix a few things in the script engine and also add some more functions and fields in to the objects.
I hope to convert the other 2 tools into script before I release test11. Sometime after the release I'll document the language and commands here. As the old scripting plugin is deprecated, I may as well use that page from something useful.
|