Blog
Scripting Scribe
Date: 29/11/2006
Well after yakking on about scripting for so long I actually ran my first script using the new engine in Scribe this morning. The javascript style engine that initially appeared in the recent i.Mage release is now also being used in Scribe. Currently the only place you can write script is in the filter object's "Script" tab. For instance this script changes the background colour of email that match the filter conditions to red:
if (Filter.TestConditions)
{
    Mail.Colour = 0xffff0000;
}
Where the hex value is in the form "0xAARRGGBB", alpha, red, green, blue. Fairly standard stuff. The first part calls back into the filter object via the DOM mapping to test the conditions defined in the Conditions tab of the filter. This way you can customize the conditions even furthur or ignore the conditions entirely and just make up your own scripted conditions. But at least if you want to use the UI for conditions you can. You get 3 predefined variables, App = the application DOM object, Mail = the mail object being filtered and Filter = the filter object the script is attached to. Of course all that will be documented in time.

I'm also thinking of having a application wide set of scripted event handlers so that you can hook events and execute scripts. This would allow you to customize various things like changing default settings on new mail or do something when the app starts. I really don't know what people will want to do yet but I'll just get it out there and see what people start hacking on to Scribe. I'm sure there will be a deluge of questions and scripts flying around for a while.

Better get a release out eh!
After fixing a bunch of bugs in the script engine this now works:
Fd = GetFolder("/Inbox");
if (Fd)
{
    Print("Got folder '" + Fd.Name + "'\n");
	
    Child = CreateSubFolder(Fd, "Test", "Mail");
    if (Child)
    {
        MoveItem(Child, Mail);
    }
}
It creates (or uses an existing) folder called 'Test' under the inbox and moves a matching email to that folder. You could for instance pull information out of the contact record associated with the sender to sort email into folders based on sender, creating more sub-folders if needed with this sort of script.

The "Print" command outputs to a new scripting console window that is hidden by default but you can show it using Tools -> Debug -> Show Scripting Console.

What would you want to do with scripted filters?
Comments:
mhf
10/12/2006 12:33pm
Could anyone edit this script so that it could be run over, say, the inbox and filter out any emails from anyone not in the contact(s) list - I have tried to do this with a normal filter but just can't get it to work - thanks.
fret
14/12/2006 3:17am
Use a condition like this:
mail.From.Contact.Folder contains "/"

That will match all your contacts, then just use the "Not" operator to reverse the matching, then add an appropriate action.
mhf
14/12/2006 11:38am
Thanks fret !!!
 
Reply
From:
Email (optional): (Will be HTML encoded to evade harvesting)
Message:
 
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.
BBcode:
[q]text[/q]
[url=link]description[/url]
[img]url_to_image[/img]
[pre]some_code[/pre]
[b]bold_text[/b]