question

Francesco V2 avatar image
0 Likes"
Francesco V2 asked Francesco V2 commented

How to use IF-ELSE condition and a proper use of brackets?!

file-funzionante-base-difettoso.fsm

Hello, I would like some advice on how to use the if-else condition. I have wrotten the code of the alghorithm that I have attached.

When I use the only IF declaration the alghorithm work without problem but when I add the else condition, I have an error that declare that I didn't use the brackets in a proper way. I have checked many times but maybe I have some problem on how to use the IF-ELSE condition.

Thank you

Francesco

FlexSim 19.2.0
if-else condition
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Francesco V2 avatar image Francesco V2 commented ·

I have talked about the ELSE in line 104.

0 Likes 0 ·

1 Answer

anthony.johnson avatar image
2 Likes"
anthony.johnson answered Francesco V2 commented

The following code is wrong:

else (solape> fracrepetidos2)

A straight else statement cannot have a condition. If you want a condition on the else, it should be an else if:

else if (solape > fracrepetidos2)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·

The syntax is bit hidden in the manual, you find it under “Writing Logic in FlexSim”: Flow Constructs.

1 Like 1 ·
Francesco V2 avatar image Francesco V2 commented ·

@anthony.johnson Do you know if si possible include a range of number in a IF condition?. I would like to have a condition that if a specific number is in a specific range, the IF condition is TRUE.

0 Likes 0 ·
Mischa Spelt avatar image Mischa Spelt Francesco V2 commented ·

You can use "&&" to check that multiple conditions are all true:

if(1 < x && x <= 10)

checks if "1 < x" and "x <= 10" are both true at the same time, which means that x is between 1 (exclusive) and 10 (inclusive).

1 Like 1 ·