Variables and IF… ELSE conditional operator

You can teach your inf to memorise various data and then use it in a conversation. For example, your inf can remember the guest’s name and then address him/her by this name.

To do this the Inf.net users now have at their disposal:

Variables
• IF…ELSE conditional operator

Variables

Using variables your inf can memorise and keep its knowledge about the guests or any text information. Currently there are 3 variables which already have a default value and 10 variables which can be given a value.

Variables with a default value have their “titles”. For example, %user_name – is a variable for memorising the guest’s name.

Such variables are used by programmers while creating the template database of the standard inf – the base of all other infs. Your inf will memorise the value of these variables forever and will use it in further conversations.

The so-called “free” variables are used for memorising any text information. This information will be memorised only in the current dialogue and will be deleted when it ends.

List of variables

Variables with default value:

%user_name (for storing the guest’s name)
%user_gender (for storing the guest’s gender)
%user_age (for storing the guest’s age)

Free variables:
%var1
%var2
%var3
%var4
%var5
%var6
%var7
%var8
%var9
%var10

Format of variables

The symbol ‘%’ is obligatory at the beginning of variables.

Note that all variables are textual. This means that their value is text. Even if you assign the variable value with "2" or "22" or even "22222" or any other number, then it will be considered by the system as a text, not a number. It means that the numbers in the name of a variable cannot be used in math calculations.

How to use variables?

First, you should tag a value to a variable, in order to assign information to it. You do it at the moment of your inf's reply.

After the value is assigned to a variable, you can:

• Enter it in the inf's reply field.
• Choose the inf's reply depending on the variable value.

If you no longer require the variable in the dialogue, then you can delete it by deleting the information from it.

Example with a guest name.

If you want your inf to memorise the guest’s name and use it sometimes in the inf's replies or pick your inf’s answer depending on the information it has, then the templates will look like this:

Template view Dialogue example
Memorising the name
$ My name is *
# Nice to meet you. [%user_name="[*1]"]
Guest: My name is Tom
Inf: Nice to meet you.
Enter the guest’s name in the inf’s reply field:
$ Bye, Inf
# Good bye, [%user_name].
Guest: Bye, Inf
Inf: Good bye, Tom.
Choose the reply depending on the value of variable %user_name:
$ Do you remember my name?
# [if (%user_name)] {Of course, I do. You are [%user_name].}
# [if (!%user_name)] {No. You didn't introduce yourself.}
Guest: Do you remember my name?
Inf: Of course, I do. You are Tom.
or
Guest: Do you remember my name?
Inf: No. You didn't introduce yourself.
If you don’t want to store the guest’s name anymore – delete the variable value
$ You are stupid.
# I don’t want to be friends with you any more and I've forgotten your name. [%user_name=""]
Guest: You are stupid
Inf: I don’t want to be friends with you any more and I've forgotten your name.


Assigning and deleting variable value

You can assign or delete the variable value in your inf's reply.

Syntax: [%variable = “value”]

You should always put the variable assignment command in square brackets – ‘[]’. They will mark that it is a variable and not just a part of a sentence. You should always put variable values in quotation marks.

Examples of assigning a variable value:
$ I dance rock-n-roll.
# I am jealous. Infs can’t dance. [%var1="likes dancing"]


$ * hate * dancing *
$ * dance * hate *
$ * do not dance *
# It’s a pity. If I were a human, I would dance. [%var1="doesn’t like dancing"]


$ I am ** years old.
# It’s a great age! [%user_age="[*1]"]


Example of deleting a variable value:
$ I don’t want you to talk about my age.
# As you wish. [%user_age=""]


Using variable value in your inf’s replies

If you want your inf to use a variable value in its replies you should enter this variable there.

Syntax: [%variable]

Square brackets are obligatory.

Example:
$ Bye, robot!
# Good bye, [%user_name]!

Check the variable value and pick your inf’s reply

Infs can reply differently depending on what the variable value is and whether the variable has or has not an assigned value. To do this you can use IF…ELSE conditional operator. Alternative beginnings with ELSE is not obligatory.

The operator is used in the reply parts of templates.

Syntax:

Check if the variable value exists.
[if(%variable)]{Inf’s reply no. 1.} [else] {Inf’s reply no. 2.}

Check if the variable value does not exist. Symbol ‘!’ in front of a variable denotes negation.
[if(!%variable)] {Inf’s reply no. 1.} [else] {Inf’s reply no. 2.}

Template examples:
$ * I am *
# [if(!%user_name)] {You keep talking about yourself. And I don’t even know your name.} [else] {[%user_name], I recognised you.}

or the template without "else" part
$ * I am *
# [if(!%user_name)] {You keep talking about yourself. And I don’t even know your name.}
# [if(%user_name)] {[%user_name], I recognised you.}

$ * Shall we dance *
# [if(%var1="doesn’t like dancing")] {But you hate dancing...} [else] {Of course! You said you liked dancing!}

or the template without "else" part

$ * Shall we dance *
# [if(%var1=" doesn’t like dancing ")] {But you hate dancing...}
# [if(%var1="likes dancing")] {Of course! You said you liked dancing!}
# [if(!%var1)]{Do you like dancing?}

Checking for the specific variable value.
[if(%variable = "value")] {Inf’s reply no. 1.} [else] {Inf’s reply no. 2.}

Template examples:
$ * Send me the link to the summer photos *
# [if(%user_name="Your Mike")] {They are on the website, as usual.} [else] {Sorry, but this link is only for Mike.}

or the template without "else" part

$ * Send me the link to the summer photos *
# [if(%user_name="Your Mike")] {They are on the website, as usual.}
# [if(!%user_name="Your Mike")] {Sorry, but this link is only for Mike.}

NOTE: Currently, you can use the variables only in the sections My templates and Responses to cues. You cannot use them in Suggested topics and Unknown inputs.