Tutorial 6

Setting a variable and using it.

Instructions
Drag and arrange states onto the canvas so that you have the following setup:


In many applications, you may wish to use the same state or sequence of states over and over again. For example, in a spelling drill you would simply want to change the words, while the rest of the dialogue structure remained the same. The best way to accomplish this in RAD is through the use of a variable.

In this application, you will create a variable called "mymotto", assign it a value, and then use it in a prompt.

Double click on the "set_a_variable" state, to open the action dialogue. In this state, enter the following text:

set mymotto "never eat yellow snow."

Be sure to pay attention to the case of the text, since Tcl is case-dependant. This will set the variable "mymotto" to have the value "never eat yellow snow."
In the prompt for the "do_something_with_it" state, place the following text:

"my motto is $mymotto"

At run time, the value of the variable "mymotto" will be substituted into the prompt, and in this case, the prompt will be "my motto is never eat yellow snow".

Run the application to see the variable substitution in action. You should also try setting the variable to some other values.