How to increment a variable var1=var1+var2 without circular reference

Hello: I’ve tried to do somthing like the += function in C promaming, to move a DC in reaction on a OnClick on a plus or minus button. It’s works but shows a “circular reference” sometimes…!? Anybody can have a look to my little example? and help me to make it better? and avoid have to put the “0 button” to reinitialize the count?
CLIC_PLUS_MINUS.skp (258.9 KB)

Thanks…

Hey, I think part of your problem is that the parent component can’t see down to the children. With DCs only the children look up, and only 1 level.

Edit: Also var1 = var1 + var2, logically speaking this is impossible with DC formula as far as I know.

Hello rwamoore:

Thank you for your time. I agree but surprised that var1=var1+var2 is not possible, if the function += exists in Ruby and many programing language. But the most curious thing is, if a DC can’t see child’s variables, is that my little example works.
In general, in programming, it may or may not work, but not a little!! no? The DC formula do the job, sometimes says “circular reference” en red, but still work!.
But I admit that, after spending hours trying to make my example work, and coming up with this far-fetched solution, I was the first to be surprised that it worked…
Is there any example of something similar, that can intereract directly to increment a variable On- screen, with one value for OnClick , without using the component otion panel?
Many thank’s.

DCs work like an excel spread sheet, not a programming language**

It works, until something is dependant on it. It updates after the redraw, so it will not affect any calculations/changes unless you right click and reDraw it, or make another change causing a redraw…

It works with a 1 click lag

Check this out might help?

Not totally sure of your end goal? perhaps there is a better way to approach it with DC formula logic…

EDIT CLIC_PLUS_MINUS.skp (269.0 KB)

Fixt.

Thank’s Ryan:
Simple and efficient.!!
Really don’t know why I invented such a complication.
Less is more, one more time.

1 Like