QiChatVariable


level_1


What is it

A QiChatVariable represents a variable in a QiChat Topic. It allows the exchange of data between java code and QiChat scripts.

For further details, see:

How to use it

Retrieving a variable

Get a QiChatVariable from a QiChatbot containing the topic where the variable is defined:

val qiChatbot: QiChatbot = ...
val nameVariable: QiChatVariable = qiChatbot.variable("name")

QiChatbot qiChatbot = ...;
QiChatVariable nameVariable = qiChatbot.variable("name");

Reading/Writing a variable

Read and write a QiChatVariable and set a listener to handle a value change:

val nameVariable: QiChatVariable = ...

nameVariable.value = "Pepper"
val name: String = nameVariable.value
nameVariable.addOnValueChangedListener { currentValue -> Log.i(TAG, "onValueChanged: $currentValue") }

QiChatVariable nameVariable = ...;

nameVariable.setValue("Pepper");
String name = nameVariable.getValue();
nameVariable.addOnValueChangedListener(currentValue -> Log.i(TAG, "onValueChanged: " + currentValue));