A new improvement is the use of variables.
AIML language there are three types of variables:
[ul]
[li] - The bot. These are used with the tag <bot name=“variable”> and are read-only.[/li]
[li] - From user. Are read and write tags are <set> and <get>. Are permanent.[/li]
[li] - The pattern. Any coincidence in a wildcard then its value can be obtained by <star> tag. These variables are temporary and its duration is within the category.[/li]
[/ul]
In the library AIMLBot (not standard).
This use of variables may cause some controversy, but the use for certain cases is necessary when more precision is required in the response.
We define new variables, and how they declare is:
[ul]
[li] - Permanent. $name[/li]
[li] - Temporary until the end of the category. $[/li]
[li] - Temporary until the end of AIML program. $$ name.[/li]
[/ul]
Why create them if they exist in the standard AIML?
I must say that its use is not necessary, but the use we can simplify the code and can use them to make code more powerful.
Let’s see one by one:
1) Temporary until the end of the category.
If we assume that:
#eat = (chew, consume, devour, gobble, ingest, munch)
#meat = (beef, veal, steak, pork, ham, #poultry)
#poultry = (chicken, turkey)
You could write such examples:
<category>
<pattern> $*0 $#eat $*0 $#meat $*0 </pattern>
<template>
<condition name=”$4”>
<li value=”#poultry”> I hate poultry </li>
<li> I like too </li>
</condition>
</template>
</category>
Temporary variables are numbered according to their appearance starting with the number one
In this example there was no need to put all the variables, just put:
*0 #eat *0 $#meat *0 </pattern>
and we would read the variable $1, put the variables that could clarify it in any position.
2) Temporary until the end of the program.
<category>
<pattern> *0 #eat *0 $#meat *0 </pattern>
<template>
<condition name=”$1”>
<li value=”#poultry”> I hate poultry {$$hate=poultry}</li>
<li> I like too </li>
</condition>
</template>
</category>
<category>
<pattern> Do you hate all poultry </pattern>
<template>
<condition name=”$$hate”>
<li value=”poultry”> I prefer beef </li>
<li> How do you know I hate poultry? </li>
</condition>
</template>
</category>
As you have noted the variable assignment I have done by putting the code between the {code} symbols. In subsequent post will move forward more in the possibilities that this new functionality.
3) Permanent. Variables could be considered as general in scope.
Same as above, but his life is permanent and is declared with a single $.
One could consider allocating {$variable = value} as a shorthand way of making what can be done by <set name=”variable”> value </set>.