Update Variable Watcher Display?

Is there a way to cause a script to wait until the variable watcher display updates before continuing?

I am incrementing a variable in a loop by 1, but the watcher display only updates every second or third iteration:

 1, 3, 5, 8, 10

Here's a link to a video that shows the result:

   https://www.dropbox.com/s/we2ztwnicsl78qo/Ping%20Pong%20Balls.mp4

I added a tenth of a second delay, but that did not change the behavior of the watcher variable display.

You could make your own "watcher" by using the write block:

untitled script pic (3)

@jens or @bh might know if it is possible force a watcher to update.

Yes, as @legoman3.14 has said, maybe the best way is to build your own construction.

Aside this, if you want to force watchers updating, you can use this

updateWatchers

Joan

The first thing is, don't use WARP or Turbo mode; those work by stealing time from screen refresh, so they pretty much guarantee that the watcher won't keep up.

Thanks for the helpful suggestions. I am not using WARP or Turbo mode, so that is not a factor.

  1. I found that a delay of 0.4 seconds was needed to allow the watcher to consistently update between each iteration.

  2. The suggestion to create a watcher using the Write command worked even with the delay set to 0 seconds.

Evidently the Write command can update more quickly than the variable watcher? In any event, thanks for the input and recommendation for a solution that worked.

Updating watchers could absorb all the available time if allowed. So it's done once in a while. With WRITE, it's not that the updating is quicker; it's that this is a change the user asked for explicitly, so it's more urgent.

That makes sense ... thanks for the explanation.

Jguille2 provided JavaScript code (above) to force a watcher update. I am not familiar with the ExecuteA code block used in this example. Is the ExecuteA code block an extension or part of a block library, and is there documentation or an example describing it? (Thanks)

It's Catalan for RUN.

Joan uses the RUN block in a Catalan translation :slight_smile: RUN, CALL and LAUNCH are very much part of Snap's primitives and well supported / documented.

I'm not sure I understand about the underlying problem. We're only updating the watcher displays about 3 times per second, but that's just the display, the value changes instantly. Is this a problem?

Oh sorry... I forgot to switch to English for the snapshot :slight_smile:

Yes, it's only "Run".

That JS code is just Snap! code. But it is not necessary to learn it. You can choose your work... and you can change it anytime you want.

  • Using other Snap! features to do it, as write block, or say... And doing what you want to do, controlling all what you do.
  • Using that JS code, building a new custom block, to get exactly what you want. And maybe you don't know how create that code. Using it as a primitive or a library.
  • Learning Snap! code and being able to do anything you want.

Yes I love Snap! because I can choose every moment what I need or what I want.

Joan

Glen wants to use the watcher as a component of a user interaction. Think about putting 5 in a variable, drawing a pentagon; putting 6 in the variable, drawing a hexagon; etc. But it's okay, @legoman3.14's solution of using WRITE instead of the watcher solves the problem.

The JavaScript to force an update of the watcher worked like a charm (once I understood that the Catalan label for the code block was the equivalent of "Run" in English). Thanks for the assist!