Optimising countdown timer: formulas for "is greater/less than or equal to"?

I’ve created a countdown timer from a user’s inputs of min and sec. Countdown timer works fine. Though I’d like for an image to change within a certain time so within an if flow function I have this:

ADD(MULTIPLY(pageVars.minWork, 60), pageVars.secWork) >= MULTIPLY(ADD(MULTIPLY(pageVars.setMinWork, 60), pageVars.setSecWork), 0.75)

Is this not a viable formula as loop stops at this point when I add it in. I tried searching up if there were any formulas for equals to or greater than and found none.

Hi, assuming that all the variables are numbers, ADD(MULTIPLY(pageVars.minWork, 60), pageVars.secWork) >= MULTIPLY(ADD(MULTIPLY(pageVars.setMinWork, 60), pageVars.setSecWork) should be a viable formula that gives a true/false value.

I’m wondering if there could be something about the placement of this flow function node in the loop that makes it stop, for example if you have 1st output: change image, 2nd output: continue loop, it might be that once the 1st output is triggered, the loop is not continued anymore even if the condition becomes false again.

Thank you for your reply,

ah, I’m testing it out again and it does work-ish
Only when I press start, stop, then start, the formulas work and images change.
But if I just press start, then only the first if condition is passed through and only 1 image change occurs (not counting initial image and final image when timer reaches min = 0, sec = 0) as the timer runs.

the formulas are as follows:
ADD(MULTIPLY(pageVars.minWork, 60), pageVars.secWork) >= MULTIPLY(ADD(MULTIPLY(pageVars.setMinWork, 60), pageVars.setSecWork), 0.75)

ADD(MULTIPLY(pageVars.minWork, 60), pageVars.secWork) >= MULTIPLY(ADD(MULTIPLY(pageVars.setMinWork, 60), pageVars.setSecWork), 0.5)

ADD(MULTIPLY(pageVars.minWork, 60), pageVars.secWork) <= MULTIPLY(ADD(MULTIPLY(pageVars.setMinWork, 60), pageVars.setSecWork), 0.25)

Since the formulas seem to work fine (though only if button changes from start/stop/start again). I’m thinking i must be doing something wrong when button is pressed?

Though all I’m doing at the start is, if button is false, set button to true and allow timer loop to start whilst also saving initial values for the user’s entry of min and sec within page variables.

Strange :face_with_raised_eyebrow: I would try to use the debugger to see what values the variables are getting (visible on the State tab), and if there is any difference between the situations where Start hasn’t yet been pressed, and when Stop has been pressed once and Start is pressed again. Maybe some variable is missing an initial value and it only gets a value once the loop runs for the first time?

mwahaha thank you Mari, got it!

seems when setting a page variable (with value number) to another page variable (also with value number), it saves it as a string (or that might have to do with the input field). Only when I pressed start/stop/start did it change to an int

1 Like