All Tutorials / Jlucben / Synbot Plugin Tutorial - interface to Syn Bot Software

Synbot Plugin Tutorial - interface to Syn Bot Software

Step 9 : SIML Tips and Tricks

Using project Editor Syn Bot Studio

Be CAREFUL :

in editing - there 's no Ctrl-Z feature - so you can not go back and cancel your last changes.

There's no SAVE AS feature for your project
So do regularly some backups of your SIML Project Folder in order to be able to backup this project to an older situation.

Build Project (Project - Build Project or F5) make a syntax analysis of your project before building and saving your SIML Project.
It works in 2 or 3 passes in order to detect first level of syntax errors.
When you got an error , error message points to line and position of error but not to the SIML file in which is located the Error.
If you have made changes to several SIML files of your project , it can be hard to identify in which file is located the syntax error.
So I recommend you do as often as possible 2 or 3 times F5 to be sure to track this firtst level of errors when you are making changes to your SIML Project.

A deeper syntax analysis is done with Project Analyse Project - you need to correct only the detected High Severity errors.

As SIML is XML , it is very sensitive.
Some syntax errors are not today completely tracked in Build and Analyse Project Features.
You need to be careful in the SIML tags attributes Syntax.

Code:

 [Response]        
[If User="flagtest" Value="testOK"]It's working fine all is OK [/If]
[/Response]


Code:

[Response]        
[If User="flagtest" value="testOK"]It's working fine all is OK [/If]
[/Response]


In this example , you will not get any syntax error, but at runtime the second form of code will never work correctly cause the If block will never be executed.
Only because the attribute value is not correct and must be Value
And it can be tricky to debug this kind of error.

Tools - SIML Playground give you access to an integrated SIML Language Tutorial.

SIML : Using Set and Map tags

In [Pattern] for a collection of words or sentences use the Map tag rather than the Set Tag

Example with Set

Code:

[Set Name="Color"]
[Item]Red[/Item]
[Item]Green[/Item]
[Item]Blue[/Item]
[/Set]


Code:

Model]
[Pattern]I LIKE THE COLOR [COLOR][/Pattern]
[Response]Aha! So you love [Match /].[/Response]
[/Model]


The sentences I LIKE THE COLOR RED , I LIKE THE COLOR GREEN , I LIKE THE COLOR BLUE will match the pattern.
But the pattern below lead to a syntax Error in Analyse project : the word RED is already adressed by the SET COLOR.

Code:

[Model]
[Pattern]DO YOU KNOW WHAT IS THE RED MENACE[/Pattern]
[Response]Yes Guy , the communist menace[/Response]
[/Model]


In a large project it can become very tricky ....

So prefer using Map tag

Code:

[Map Name="Color"]
[MapItem Content="Red" Value="T" /]
[MapItem Content="Green" Value="T" /]
[MapItem Content="Blue" Value="T" /]
[/Map]


Code:

[Model]
[Pattern]I LIKE THE COLOR [Map:COLOR][/Pattern]
[Response]Aha! So you love [Match /].[/Response]
[/Model]


And all will be working fine

SIML : Using the Map tag

As in Set , you cannot have in a Map duplicate for Map entries contents.
Be CAREFUL if you use the Reverse attribute for a Map.
In this case , There can be also no duplicates for content values of Map entries.
In case of duplicates , value corrresponding to first entry will be return with Get.

Be CAREFUL to the order of entries in the Map - Example below will lead to unexpected results

Code:

[Map Name="Color"]
[MapItem Content="Red" Value="1" /]
[MapItem Content="Red Blue" Value="2" /]
[MapItem Content="Red Brown" Value="3" /]
[MapItem Content="Green" Value="4" /]
[MapItem Content="Blue" Value="5" /]
[MapItem Content="Red" Value="6" /]
[/Map]/[code]
[code][Model]
[Pattern]I LIKE THE COLOR [Map:COLOR][/Pattern]
[Response]Aha! So you love [Match /] and index in color table is [Map Get="COLOR"][Match /][/Map][/Response]
[/Model]


I like the color Red Blue : Aha! So you love red blue and index in color table is 1 5
I like the color Red Brown : Aha! So you love red blue and index in color table is 1 Brown

If you change the order of entry in the map

Code:

[Map Name="Color"]
[MapItem Content="Red Blue" Value="2" /]
[MapItem Content="Red Brown" Value="3" /]
[MapItem Content="Red" Value="1" /]
[MapItem Content="Green" Value="4" /]
[MapItem Content="Blue" Value="5" /]
[MapItem Content="Red" Value="6" /]
[/Map]


Results will be as expected :
I like the color Red Blue : Aha! So you love red blue and index in color table is 2
I like the color Red Brown : Aha! So you love red blue and index in color table is 3
Aha! So you love red blue and index in color table is 2

SIML : Using the Map tag - Get the value of a Map

[Map Get="name of Map"]Entry Content to search[/Map] returns the value corresponding to the Entry content to search.

If the Entry is not found in the Map , result will be the Entry Content specified.
[Map Get="COLOR"]Yellow[/Map] will return Yellow

SIML : Using the Bind tag

Binding allows values of adapters to be mapped to unique keys that upon evaluation get replaced with the returned value of the adapter. Binding is very useful to assign values to Tag attributes

Example Comparing 2 Bot variables values

Code:

[If Var="Controlrobottype" Value="{Bind Var:Controlrobottype1}"][User Set="indrobot"][/User][/If]


To compare User variables value Controlrobottype and Controlrobottype1

SIML : Using the Goto tag

Once you have caught a pattern at some point you may want to redirect the pattern-search to a different value. The value of the Goto elementt tells the Bot that it should recursively use the pattern defined within it and search for a response.
Goto element plays a major role in breaking down complex sentences into simpler ones.

The Goto tag is very powerful but remember always that after exécution of the called model, control is set back to the caller
So for example the last reponse will not be set to the goto pattern reponse but to the caller response.

SIML : Using If Else and Switch Tags

Be careful as nested If or nested Switch can have impredictible results.
You can better nest alternate If and Switch tags