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

Synbot Plugin Tutorial - interface to Syn Bot Software

Step 5 : Working with Synbot SIML variables

In SIML files , you can get , set and test the value of variables.

3 types of variables can be used :

1. Global to the Bot : BOT variables
2. Specific to a userid : USER variables
3. Temporary for a user query : VAR variables

All USER variables values are saved in a file either with the Save context Button during a session or at the end of the bot session for a specific user (Stop Button of the plugin)
They are restored from the file saved values when you start a new session with the same userid.
When no saved file is existing for the user , the context is restored from the User-Settings.Siml file of your active SIML project( Same initial context for every userid)

In the same manner , All BOT variables values are also saved and restored when you start a new session with any userid.
When no saved file is existing ,the context is restored from the Bot-Settings.Siml file of your active SIML project.

In plugin Configuration Form , you need to configure folder where saving files will be located - Bot Save Directory Path
Saving File names are automatically generated : and prefixed by userid for the session - userid-settings.siml

BE CAREFUL - If you modify content of Bot-settings or User-settings SIML files in your SIML project (with Syn Bot studio) these modifications are not applied automatically to the saved files.
If you want so , you need to report modifications in the saved files

Setting the value of a variable :

During a bot session , variables values can be set either in SIML Bot files or in EZ Builder scripts.
Variable value type is always a string type.
If the variable doesn't exit , it is created.
You can set several values (A list) for the same variable.

In SIML :
the tags Bot , User and Var are used to get or set the value of variables in the block Response.
for example :

Code:

[User Set="Userlanguage"]fr[/User]

the USER variable Userlanguage is set to value "fr"

If you want to add a list of value to a variable - replace the SET keyword by ADD

In EZ Builder Scripts :

Code:

Setbotvar("variabletype:variablename" , "value")

where variabletype equal var ou user or bot
For example : Setbotvar("user:Userlanguage" , "fr")

or for using in Blockly

Code:

$Botvarname = "user:Userlanguage"
$Botvarvalue = "fr"
ControlCommand("Synbot plugin", Setvar)



Getting the value of a variable :

In SIML :
the tags Bot , User and Var are used to get or set the value of variables in the block Response.
for example :

Code:

[User get="Userlanguage" /]

return the value of the USER variable Userlanguage

If several values are set for the same Bot variable , only the first one is returned with GET ....
If you want to get the the list of values for a variable - replace the GET keyword by LIST
The value of the BOT variable "List-Separator" is used to configure the separator between every value of the list.

In EZ Builder Scripts :
Gettbotvar("variabletype:variablename" )
For example :

Code:

Getbotvar("user:Userlanguage")


or for using in Blockly

Code:

$Botvarname = "user:Userlanguage"
ControlCommand("Synbot plugin", Getvar)


Result value is returned in $Botvarvalue EZB variable
If several values are set for the same Bot variable , only the first one is returned ....List is not supported in this version

User-inserted image

Testing the value of a variable

In SIML :
use the [If] or [Switch] tags
For example

Code:

[If User="Userlanguage" Value="fr"][Goto xml:space="preserve"]XXXXXXINTERPRETATIONOFMOVEMENTFLAGS [Match Index="2" /][/Goto][/If]


In EZ Builder Scripts :
Get the value of the variable
Use logic operators with the result returned in $Botvarvalue EZB variable

For complementary informations - look at SIML tutorial below

developer.syn.co.in/tutorial/siml/elements/bot.html
http://developer.syn.co.in/tutorial/siml/elements/usersettings.html
http://developer.syn.co.in/tutorial/siml/elements/variable.html