i am confused about using the or-operator

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

i am confused about using the or-operator

Post by Andi »

Hi all!
I have a very special problem:

i try to receive two characters with my rs232 component.
First i try to check if the first incoming character is an 'a' or 'b' or 'c'.
If it is one of the following characters, i try to check the second character if it is an 'a' or 'b' ... or 'o'.

At the moment i check every single incoming character with a single if-command. Now i have the problem that i have
more than 45 if-commands in my source code.

When i am trying to use the || in my if-command and compare the incoming rs232 value with my test variable
(if test= 'a' || 'b' || 'c' )
...
...
it doesnt work.

What is my mistake?
plz help me!

Regards,andi

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: i am confused about using the or-operator

Post by Sean »

The || operator performs the locical OR operation. Anything that does not have the value 0 is treated as TRUE.

The expression 'a' || 'b' || 'c' will always be TRUE because all the parameters are TRUE.

The code to test each parameter individually would be:

if (test='a') || (test='b') || (test ='c') .... etc.

Here each individual comparison provides the TRUE/FALSE results that are ORed together.

Post Reply