Scripting Scribe

Overview
Scribe can execute scripts to extend it's functionality in the following locations: Scripts are written in a C like language, the exact syntax is described here. Scripts are stored in 2 places, either in the Script tab of a filter or as a .script file in the Scripts subfolder where the executable is located. Files with the extension ".script" in that folder are loaded and executed when Scribe starts, and they for the most part install a call back that is called when some event happens later. Scripts can print debugging information to the scripting console via the Print(...) method. That console can be openned via the Debug -> Show Scripting Console menu.

Scribe Specific Methods
These methods are defined for all scripts run within Scribe, in addition to the various scripts defined by the system library (which are available in any script enabled Lgi application).

File Based Scripts
When you create a file based script in the ./Scripts subfolder it has to have the extension .script. It will only be loaded at startup, changes to the script after Scribe loads will not be loaded until next start up. Scripts should be utf-8 text with \r\n or \n end of line characters. They should have a method called "Main" and optionally one or more callback methods. The Main function should register the callback(s) via AddToolsMenuItem, AddThingMenuCallback, AddThingUiButton or AddCallback.

See the existing scripts in that folder for some examples.

Filter Based Scripts
Filter based scripts exist in the Script tab of a filter object. When the script tab has some content any existing filter conditions are ignored and the script is executed. There doesn't need to be a method defined in the script. Several pre-defined variables are available:

In your script you can call being into the filter object to evaluate the conditions in the filter against the mail object being filtered by using the syntax:

Filter.TestConditions
Which returns a boolean true of the mail matches the filter's conditions or false otherwise. Also to execute the actions attached to the filter you can call:
Filter.DoActions(Mail)
The default behaviour of a filter with no script is:
if (Filter.TestConditions)
{
    Filter.DoActions(Mail);
}
You can use that as a template to build up to the functionality you want. Alternatively you can replace Filter.DoActions(...) with a set of custom calls to manipulate objects directly from the script.

To stop further filtering of the current email use the StopFiltering method:
Filter.StopFiltering();
© 1999-2016 Matthew Allen