Writing Simkin Scripts


Simkin script can be placed within an XML document, a TreeNode (Java) or skTreeNode (C++) file or from some other source, such as a database.

Using Simkin, your script can call other methods within the document, or within other C++ or Java objects. It can also manipulate the data elements of the document.

XML or TreeNode documents can contain a mixture of data elements and script elements.

Slightly different syntax is used in the two different formats.

Here's a method in an XML document:

<function name="method" params="arg">
self.foo();
</function>
Here's a method in a TreeNode file:
method [(arg){
self.foo();
}]
In XML the parameters are defined within the params attribute, in TreeNode, they are declared within "(" ")"

Here's a more detailed example in XML:

<myobject>
<Field1>Value</Field1>
<function name="Method" params="arg">
trace("Hello World"); 
trace("Field1=" # Field1);
trace(arg);
</function>
</myobject>
In this example the XML file contains a data element called "Field1" and a function called "Method".

The data field can be any standard XML field. The function element has two attributes:

The text within the element contains Simkin script as a series of statements separated by ";".

In the example the method calls another method called "trace". This is actually a method within the underlying C++ or Java application.

The example also retrieves the "value" of the field "Field1". This is the text that exists between the opening and closing of the "Field1" tag. The "#" operator adds two strings together.

You can also access attributes and sub-tags of elements:

<myobject>
<Field1 attribute="value">
<SubField1>
MyValue
</SubField1>
</Field1>
<function name="Method">
trace("Field1:attribute=" # Field1:attribute);
trace("Field1.SubField1=" # Field1.SubField1);
</function>
</myobject>

The Simkin Syntax is a very simple, like JavaScript, and contains statements such as "if" and "while", and operators for doing mathematics and string manipulation.

Simkin script can call into methods implemented either in C++ or Java or in Simkin script itself.

Please see this example script Example.xml
Here is the equivalent in TreeNode: Example.s