

| Type | Description | |||
| Template as Variant | A string expression that specifies the Template to execute. | 
The following sample opens the Windows Internet Explorer once the user clicks the control ( /COM version ):
AttachTemplate("handle Click(){ CreateObject(`internetexplorer.application`){ Visible = True; Navigate(`https://www.exontrol.com`) } } ")
  This script is equivalent with the following VB code:
Private Sub TreeCube1_Click()
    With CreateObject("internetexplorer.application")
        .Visible = True
        .Navigate ("https://www.exontrol.com")
    End With
End Sub
  The AttachTemplate/x-script syntax in BNF notation is defined like follows:
  
  <x-script> := <lines>
  <lines> := <line>[<eol> <lines>] | <block>
  <block> := <call> [<eol>] { [<eol>] <lines> [<eol>] } [<eol>]
  <eol> := ";" | "\r\n"
  <line> := <dim> | <createobject> | <call> | <set> | <comment> | <handle>[<eol>]{[<eol>]<lines>[<eol>]}[<eol>]
  <dim> := "DIM" <variables>
  <variables> := <variable> [, <variables>]
  <variable> := "ME" | <identifier>
  <createobject> := "CREATEOBJECT(`"<type>"`)"
  <call> := <variable> | <property> | <variable>"."<property> | <createobject>"."<property>
  <property> := [<property>"."]<identifier>["("<parameters>")"]
  <set> := <call> "=" <value>
  <property> := <identifier> | <identifier>"("[<parameters>]")"
  <parameters> := <value> [","<parameters>]
  <value> := <boolean> | <number> | <color> | <date> | <string> | <createobject> | <call>
  <boolean> := "TRUE" | "FALSE"
  <number> := "0X"<hexa> | ["-"]<integer>["."<integer>]
  <digit10> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  <digit16> := <digit10> | A | B | C | D | E | F
  <integer> := <digit10>[<integer>]
  <hexa> := <digit16>[<hexa>]
  <color> := "RGB("<integer>","<integer>","<integer>")"
  <date> := "#"<integer>"/"<integer>"/"<integer>" "[<integer>":"<integer>":"<integer>"]"#"
  <string> := '"'<text>'"' | "`"<text>"`"
  <comment> := "'"<text>
  <handle> := "handle " <event>
  <event> := <identifier>"("[<eparameters>]")"
  <eparameters> := <eparameter> [","<eparameters>]
  <parameters> := <identifier>
  
  where:
  
  <identifier> indicates an identifier of the variable, property, method or event, and should start with a letter.
  <type> indicates the type the CreateObject function creates, as a progID for /COM version or the assembly-qualified name of the type to create for /NET or /WPF version
  <text> any string of characters
  
  The Template or x-script is composed by lines of instructions. Instructions are separated by "\n\r" ( newline characters ) or ";" character.
The advantage of the AttachTemplate relative to Template / ExecuteTemplate is that the AttachTemplate can add handlers to the control events.