One of MTP's most powerful features is its support for user defined BASIC scripts (plugins) and their ability to manipulate data that has been extracted from incoming text. Scripts are stored as text files with an extension of 'txt' and are held in the 'BASIC Scripts' folder within the MTP user area. A BASIC script is a self contained program that is executed by MTP. BASIC scripts communicate with the application via two commands, 'Input' and 'Print'. That is, when the application starts execution of a script it may pass a single text input via the Input command and when the script has finished executing it may return to the application a single text output using the 'Print' command.

For example, the script ...

Dim inputText, firstWord as String

inputText = Input("")
inputText = Trim(inputText)
firstWord = NthField(inputText, " ", 1)
firstWord = TitleCase(firstWord)
Print firstWord

... accepts text input from the application via the Input command into the variable 'inputText'. The data is then manipulated and the variable 'firstWord' is set to the first word of the data in title-case. The variable is then returned to the application via the Print command.

Scripts can be run from within variables. If the rules associated with a variable contain a reference to a BASIC script then when the variable is executed it will extract data from the input text and then pass that data to the script. The script will manipulate the data and return it to the variable which may then further process it. For example, a 'First Name' variable may extract the customer's first name by passing the extracted customer name from the input text and passing it to the script above which will extract the first word e.g. 'john smith' -> 'John'.

Editing, Compiling & Testing

The creation/modification of scripts is achieved via the 'BASIC Scripts' window launched by selecting the 'BASIC Script Maintenance' option of the File menu.

        BASIC Scripts Editor Window

When the script window is initially displayed it will not contain any BASIC scripts. This will result in a dialog being displayed asking if the bundled, example scripts are to be loaded into the BASIC script window framework. Clicking the 'Load Example Scripts' button loads them into the scrollable list to the left of the window. The buttons beneath the list provide facilities for editing, renaming, duplicating, deleting and creating new scripts. To edit the contents of a script simply click the name of the script and it will appear in the editing panel to the right of the script list. Clicking the 'New' button results in a new template script being displayed in the editing pane.

The script editing pane highlights BASIC keywords and formats the script text as it is entered/displayed. A contextual menu provides functions that assist in the construction of a script. One option provides for the insertion of BASIC code constructs into the script. Another option displays a floating window that contains a scrolling list of available BASIC functions that may be included into the script. Dragging-and-dropping a function name to the editor pane results in the insertion of that function into the script.

Once a script has been created it may then be tested by clicking the 'Test' button or by selecting the 'Test Script' option from the 'Script' menu. Testing commences with compilation of the code that checks the syntax of the script. If any errors are detected the test process is aborted and the errors are displayed in the floating 'Compilation Errors' window. The script lines in error are also marked by a red cross in the left hand margin of the edit pane. Double-clicking an error in the 'Compilation Errors' window will set the edit pane cursor to the line of script code that generated the error. 

Once all errors have been eliminated the process continues with the display of the floating 'Script Test' window. This window allows the input of any input text that the script is to process. Clicking the 'Test' button will result in the entered text (if any) being passed to the compiled script and any output is then displayed in the 'Test Results' section of the window.

Supported Elements

Variables, Constants, Operators & Comments.

+, -, *, /, \, Mod, <, =, >, <=, >=, <>.
And, Not, Or.
', //, and REM 

Data Types

Integer, Single, Double, Boolean, String, Color, Object, Variant

Control Structures 

... Next
... Loop
If... Then... End If
Select Case
... End Select
Return statement

Input and Output

Input(Prompt as String) - Retrieves input from the user.
Print(String) - Sends to the application.