An SPL template is constructed in the programming language of the program code you wish to generate. The template contains snippets of SPL instructions to integrate MobileTogether data into the generated program code. SPL instructions are enclosed in square brackets. Here, for example, is a template to generate an XML file (written in XML), with the SPL instructions highlighted in yellow.
<?xml version="1.0" encoding="utf-8"?>
Multiple statements can be included in a bracket pair. Additional statements have to be separated from the previous statement by a new line or a colon. Valid examples are:
[$x = 42
$x = $x + 1]
[$x = 42: $x = $x + 1]
Text not enclosed by square brackets is written directly to the output. To generate square brackets, escape them with a backslash: \[ and \]. To generate a backslash, use \\.
Comments inside an instruction block always begin with a ' character, and terminate on the next line, or with a closing square bracket.
•Integer: Also used as boolean, where 0 is false and everything else is true
•String. See also String Mechanisms.
•Object: Provided by MobileTogether. For example, the $Options object.
Variable types are declared by first assignment:
[$x = 0] means that x is now an integer.
[$x = "teststring"] means that x is now a string.
Strings are enclosed in double quotes. \n and \t inside double quotes are interpreted as newline and tab, \" is a literal double quote, and \\ is a backslash. String constants can also span multiple lines. String concatenation uses the & character:
[$BasePath = $outputpath & "/" & $JavaPackageDir]
Objects are MobileTogether structures. Objects have properties, which can be accessed by using the . operator. It is not possible to create new objects in SPL, but it is possible to assign objects to variables. For example:
This example outputs the word class, followed by a space and the value of the Name property of the $class object.
Use IF statements, with or without the ELSE clause, as follows. Do not use round brackets around the condition.
[if $namespace.ContainsPublicClasses and $namespace.Prefix <> ""]
whatever you want ['inserts whatever you want, in the resulting file]
Use FOREACH statements to iterate, as follows:
foreach object in collection
[foreach $class in $classes
if not $class.IsInternal
] class [=$class.Name];