Page 1 of 1

If then in a calculation

Posted: Sat May 04, 2024 1:48 pm
by RGV250
Hi,
I am a bit puzzled if this is possible or not, in the help for calculations it shows >, <, >= and so on but I cannot figure out how to use them.
I would like to be able to do simple things like

xyx = xyz + 1
if xyz > 10 then xyz = 0

So far I have had to do the addition and then use a decision which seems very cumbersome.

Inc and Dec would be a nice feature to add as well to make things tidier.
In a different program I can use

Inc xyz to increment by 1
or
Inc xyz,10 to increment it in steps of 10

Regards,
Bob

Re: If then in a calculation

Posted: Sat May 04, 2024 2:54 pm
by mnfisher
One for the first is

Xyz = (Xyz +1) % 10

Which will cycle back to 0 when Xyz reaches 10 - xyz = 0..9

Re: If then in a calculation

Posted: Sat May 04, 2024 4:22 pm
by RGV250
Thanks, that is a neat solution.

Bob

Re: If then in a calculation

Posted: Sat Jul 20, 2024 3:10 pm
by S_VE
Hi

Good solution from martin

Just curious to know if we can use "IF.... THEN.... ELSE.... " directly inside CALCULATION

it will be very useful if we can.

Re: If then in a calculation

Posted: Sat Jul 20, 2024 3:20 pm
by kersing
Don’t you think using if then else in a calculation would change readability of flowcharts? Now looking at the icons you get a feel for the program flow. With if then else in a calculation you could create a obscured flow.