First time here? Check out the FAQ!
x

Why doesn't this EventVariable expression work?

0 votes
612 views
I'm scratching my head here... I don't see any fader for !BPM or !div in the VCS, and I don't see any counting... What am I doing wrong?

| index clock |

index := EventVariable new initialValue: 0.

clock :=(1 bpm: !BPM) triggerEvery: !div.

clock evaluate: (index <+ (index +clock)).
index.
asked May 14, 2018 in Capytalk & Smalltalk by cristian-vogel (Master) (8,440 points)

1 Answer

0 votes

Ah - syntax thing...

I need a comma at the end of the evaluate: message

Working code is:

 

| index clock |

index := EventVariable new initialValue: 0.

clock :=(1 bpm: !BPM) triggerEvery: !div.

clock evaluate: (index <+ (index +clock)),
index.

answered May 14, 2018 by cristian-vogel (Master) (8,440 points)
or you leave it on the stack using:
clock evaluate: (index <- (index + clock))
Should that be "<~" to leave on the stack?
You definitely don't want to leave it on the stack in this case. But yes
<~ is an assignment
<+ is an assignment plus pop
Could you use
clock evaluate: (index <+ (index + 1)),
What does the comma mean in this instance? Is it a special use of comma just for the arguments for "evaluate:"?

Is the reason you don't want to leave a value on the stack because that's the job of "evaluate:" to leave the result of the last argument on the stack?
clock evaluate: (index <+ (index + 1)),
index

Since you put index as the last statement, it's not necessary to leave the result on the stack (you're explicitly saying that you want index to be the result of the whole expression.
...