
| Type | Description | |||
| String | A string expression that indicates the control's template. |
The control's template uses the X-Script language to initialize the control's content. You configure this through the Template property page of the control, which lets you edit the control's Template property. The Template property lets you execute code by passing it a string of instructions (the "template string"). The ExecuteTemplate property runs a template script and returns the result.
Most of our UI components include a Template page you can access in design mode. Regardless of which programming language you're using, this WYSIWYG Template editor lets you preview the component's features quickly.
The Template page lets you set up the control's look and feel visually, using the simple but powerful x-script language. The control preview appears on the left side of the page, and an editor for writing initialization code appears on the right. As you type new instructions, the control's appearance updates immediately. When you click Apply, the script is saved with the container and will run automatically whenever the control initializes at runtime. Any component with a WYSIWYG Template page also exposes a Template property, which runs code supplied as a string (the template string).
A template (x-script) consists of lines of instructions. Instructions are separated by newline characters ("\n\r") or by a semicolon (";"). The template string can contain any number of instructions, and each instruction can be a property call, a method call, or an assignment statement. The template string can also contain comments, which start with a single quote (') and continue to the end of the line.
The BNF notation for the x-script language is as follows:
<script> ::= <statement> | <statement> <separator> <script>
<separator> ::= "\n\r" | ";"
<statement> ::= "Dim" <variables> | <expression> "=" <value> | <expression>
<expression> ::= <identifier> <suffix> | <expression> "{" <script> "}"
<suffix> ::= <empty> | "." <identifier> <suffix> | "(" <arguments> ")" <suffix>
<variables> ::= <identifier> | <identifier> "," <variables>
<arguments> ::= <empty> | <value> | <value> "," <arguments>
<value> ::= <identifier> | "True" | "False" | <number> | <date> | <string>
Each x-script line can take one of the following forms:
Example: Dim h, h1, h2, declares three variables named h, h1, and h2.
Example: h = InsertItem(0, "New Child") inserts a new item at index 0 and assigns the handle of the new item to the variable h.
Example: Background(0) = RGB(255,0,0), changes the background color of the control's part with index 0 to red.
Example: Images("c:\temp\copy.ico") calls the Images method with the specified ICO file path as an argument.
Example: Columns.Add("Column1"){HeaderAlignment = 2;Alignment = 2;} adds a new column and sets its HeaderAlignment and Alignment properties to 2 (right).
Example: Columns.Add("Column1").Def(7) = RGB(255,0,0) adds a new column and sets its header background color.
X-script also supports the following literal (constant) expressions:
Example:Trueis the boolean value true, equivalent of -1;Falseis the boolean value false, equivalent of 0.
Example:13is the integer 13;12.45is the decimal value 12.45.
Example: #12/31/1971# represents December 31, 1971.
Example: "text" represents the string "text".
X-script also provides these general-purpose functions:
Example: Me.BackColor property refers to the control's BackColor property.
Example: BackColor = RGB(255,0,0) sets the control's background to red.
Example: Picture = LoadPicture("C:\MyImage.jpg") loads the image from the specified file and assigns it to the Picture property.
Example: CreateObject("Exontrol.Print")
{
AutoRelease = False
PrintExt = Me
Preview()
} creates a new instance of the Exontrol.Print class, sets its AutoRelease property to False, assigns the current control to its PrintExt property, and calls its Preview method (preview the control's content and release the object when closing the preview window). The print and print preview features is not available for all exontrol controls, please check the control's documentation for more information.