Forum Documentation Showcase Pricing Learn more

Limiting the value of a number

How would I stop a numerical value going below zero, efficiently.

For example, each time an icon is clicked it deducts one, but I don’t want that value to go below zero.

I originally used a ‘Do every 0.1 seconds’ to check the value of a number and if it’s <0 then change it to zero.

What other ways can I achieve this? I must be missing something.

You don’t need to use a Do Regularly there. In fact, this use case is very rare, if you use it often, that probably means you’re doing something fishy. Remember, Bubble is real-time…

In this case, i would add a condition on the workflow that is triggered when the icon is clicked, and say: when whatever-thing-youre-modifying’s value > 0

That way, if it’s negative, the workflow doesn’t get run.

1 Like

Thanks @emmanuel, now I understand and it worked a treat.

1 Like

Great