If then in a calculation

For general Flowcode discussion that does not belong in the other sections.
Post Reply
RGV250
Posts: 282
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 31 times

If then in a calculation

Post 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

mnfisher
Valued Contributor
Posts: 1224
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 119 times
Been thanked: 628 times

Re: If then in a calculation

Post by mnfisher »

One for the first is

Xyz = (Xyz +1) % 10

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

RGV250
Posts: 282
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 31 times

Re: If then in a calculation

Post by RGV250 »

Thanks, that is a neat solution.

Bob

S_VE
Posts: 24
Joined: Tue Jan 26, 2021 6:10 am
Has thanked: 30 times
Been thanked: 1 time

Re: If then in a calculation

Post 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.
S_V

kersing
Valued Contributor
Posts: 181
Joined: Wed Dec 02, 2020 7:28 pm
Has thanked: 73 times
Been thanked: 63 times

Re: If then in a calculation

Post 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.

Post Reply