An EventVariable is a variable whose value can be changed during run time in a Capytalk expression using the assignment operators <+ or <~.
This is different from a Smalltalk variable which can change state during compile time using the assignment operator, :=, and is no longer referenced or updated while the Sound is running.
It's pretty rare to need an EventVariable, but if you want to create a Capytalk expression where the current value depends on the previous value, you can use an EventVariable to hold onto the previous state. For example, if you wanted to increment the value of a parameter each time you received a trigger, you would need to keep track of the previous value in order to increment it when the next button press comes in. To hold onto the previous value, you could use an EventVariable, for example:
| prev |
prev := EventVariable new initialValue: 0.
!Trigger
true: (prev <+ (prev + 1))
false: (prev)
Let's say, instead, that you wanted to create a Capytalk expression using Smalltalk to build it up. In this case, you might use a Smalltalk variable to hold onto the previous Capytalk expression as you add new extensions to it, for example:
| kernel |
kernel := !Value.
1 to: 4 do: [ :i | kernel := kernel + (!Offset suffix: i)].
kernel
which, if you select it and evalute it using Ctrl+Y evaluates to:
!Value + !Offset1 + !Offset2 + !Offset3 + !Offset4
In this case, you are building an expression at compile time, and then sending that expression to the Pacarana where it can be evaluated while the Sound is running and respond to changes in !Value in the !Offsets.