Scribe Scripting API

Basics

The main syntax of the language is somewhat modelled after Javascript and C, however you don't need to declared variables with "var". And some more advanced features are missing like passing functions around as variables, ternary operators etc.

When scripting in Scribe you will encounter objects, like email, the application object, a contact and so on. These are implemented internally as C++ objects that inherit from the GDom class. You can read and write various properties via a simple naming convention. For instance if you have a pointer to a mail object in that variable 'm' then you can access the sender's email addres using the syntax 'm.From.Email'. You can look up the fields available in the various objects using the Scribe DOM reference.

Objects in Scribe generally have a type associated with them. Folders can contain items of one type, except the trash which can have all types of objects. The types have codes associated with them, and this is the mapping:
MAGIC_NONE0x00000000No type
MAGIC_MAIL0xaaff0001Mail item
MAGIC_CONTACT0xaaff0002Contact item
MAGIC_FOLDER0xaaff0003Folder of items
MAGIC_MAILBOX0xaaff0004Root of mail tree (nothing-abstract)
MAGIC_ATTACHMENT0xaaff0005Mail attachment
MAGIC_ANY0xaaff0006Trash folder type (accepts any object)
MAGIC_FILTER0xaaff0007Used to match messages against
MAGIC_FOLDER_20xaaff0008Folder v2
MAGIC_CONDITION0xaaff0009Filter condition
MAGIC_ACTION0xaaff0010Filter action
MAGIC_CALENDAR0xaaff0011Calendar event
MAGIC_ATTENDEE0xaaff0012Event attendee
MAGIC_GROUP0xaaff0013Group of contacts

There are a number of example scripts in the ./Scripts sub-folder in the scribe directory, and a copy of this file. Scripts in the ./Scripts sub-folder are automatically scanned and loaded into the tools menu of Scribe on startup.

They need to define a main function, which is called when Scribe starts. In your main function you should do any intialization required and then setup a callback hook depending on what type of functionality you're implementing.

Library Functions:

Built In Language Functions

string Strchr(str, ch[, len]);

Finds a unicode character in a string.

Arguments:
Returns:

string Strstr(str1, str2[, case_insensitive[, len]]);

Finds a string in another string.

Arguments:
Returns:

int Strcmp(str1, str2[, case_insensitive[, len]]);

Compares 2 strings.

Arguments:
Returns:

string Substr(str, start[, len]);

Returns a part of another string.

Arguments:
Returns:

string LoadString(id);

Loads a string from the resource file.

Arguments:
Returns:

hashtable NewHashTable();

Returns an empty hash table object.

Arguments:
Returns:
See also this page on container type handling.

list NewList();

Returns an empty list object.

Arguments:
Returns:
See also this page on container type handling.

bool DeleteElement(container, index);

Returns an empty list object.

Arguments:
Returns:

string ReadTextFile(filename);

Returns the contents of a text file.

Arguments:
Returns:

bool WriteTextFile(filename, data);

Writes the contents of a variable to a text file.

Arguments:
Returns:

Scribe Specific Functions

bool LoadFolder(folder);

Loads the items in a folder. By default folders are not loaded, to access their items you first have to load them using this function.

Arguments:
Returns:

string SelectFolder(parent_wnd[, limit_to_type]);

Displays a dialog to the user so they can select a folder.

Arguments:
Returns:

object GetFolder(path);

Returns a folder object.

Arguments:
Returns:
By default folders are not loaded, so to access the items inside them use the LoadFolder method.

object CreateSubFolder(parent_folder, child_name, child_type);

Creates a new folder object.

Arguments:
Returns:

bool CreateThing(type);

Creates a new Thing.

Arguments:
Returns:

bool MoveThing(dest_folder, object);

Moves an object to another folder.

Arguments:
Returns:

bool SaveThing(folder, object);

Saves a new object into a folder.

Arguments:
Returns:

bool Delete(object);

Deletes an object to the trash

Arguments:
Returns:

void Print(string);

Prints a string to the debug console.

Arguments:
Returns:
You can open the debug console using the Tools->Debug->Show Scripting Console menu.

int MsgBox(parent_wnd, msg, title[, type]);

Displays a message box.

Arguments:
Returns:

Scripting Hook Functions

int AddToolsMenuItem(String MenuText, String CallbackFunctionName);

Setup a new callback that shows up in the main window's Tools menu

Arguments:
Returns:

int AddThingMenuCallback(String MenuText, int ThingType, String CallbackFunctionName);

Setup a new menu item in the context menu of Things (mail, contact, calendar event etc).

Arguments:
Returns:

int AddThingUiButton(int ThingType, String ButtonText, String ButtonImg, String CallbackFunctionName);

Setup a new menu toolbar button in the window UI of a Thing object (mail, contact, calendar event etc).

Arguments:
Returns: