A When Variable Changed Block would be very useful.
eyra
Offline
All "when <condition>" or "wait until <condition>" implicitly have a "when <set of variables> changes", so providing a "when <variable> changes" block should be simple. The main question is whether enough users would find it useful enough (and not too many users would be confused by it).
I was going to suggest generalizing to a condition: <variable changed>, which would work fine in "wait until" or "when" blocks, and even makes sense in "repeat until", but would be hard to assign semantics to in "if" blocks.
Offline
I was thinking theexact same thing! It's in my "I would like..." topic
Offline
Kevin, my only thought around the implementation is that "variable changed" is an event, or message if you will. To me, it doesn't belong as a condition, because what you would truly be asking is "If <variable has changed> then...". I think that a When <variable changes> "hat" block is absolutely reasonable (and a GREAT suggestion), because it is just another way to react to a message of sorts.
I also don't know how you could use a <variable has changed> criteria, since you have no way of clarifying <variable has changed since when?>
Of course, I have done this using a forever If block:
Forever If not<value = oldValue>
...Do Something
oldValue = value
end loop
By doing it this way, you are able to tell that the value has changed since the last time i looked at it
I think that giving a user the ability to just check "has a value changed?" opens up a concept that the target audience may not be ready for...
Does this make sense?
Mike.
Offline
Let me try to use your language...
YeS I aM sURE.
eYRa
Offline
mdusoe, I agree that the semantics for <variable x changed> is not clear in an if statement. I think that your suggestion that it means "since the last time this condition was checked" is a reasonable semantics---essentially each instance of the <variable x changed> block would create a shadow variable "oldx" and the block would be implemented something like
<test= x!=old_x, oldx := x, return test>
Of course, wait and when blocks could be more efficiently implemented with daemons.
Offline