IF Statement help

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

Moderators: Benj, Mods

Post Reply
ALAN_26
Posts: 84
Joined: Sat Apr 29, 2006 3:36 pm
Location: MALTA

IF Statement help

Post by ALAN_26 »

Hi Steve or ben


Is it possible to make an if statement for these 2 factions using 1 if statement for each function ?


--> If variable is between 22 and 33

--> If variable is 2 or 5 or 44

I need to make this function to interface a 4 wire resistive touch screen , it produces
An X and Y voltages which are going to be connected to the pic ADC’s than converted To variables .


Thank in advance


Regards, Alan cilia

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

In Flowcode v2, you need to use multiple decision icons, such as "if var >= 22" and "if var <= 33".

If Flowcode v3, you can use the "&&" to link multiple decisions together. For example, "if (var >=22) && (var <= 33)".

Note that the word "AND" is used for a "bitwise" AND in all Flowcode versions.

ALAN_26
Posts: 84
Joined: Sat Apr 29, 2006 3:36 pm
Location: MALTA

Post by ALAN_26 »

OK THANKS WORKS 100%

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times

Re: IF Statement help

Post by Ondra »

steve wrote:Note that the word "AND" is used for a "bitwise" AND in all Flowcode versions.
Steve Could you explain the above statement a little more.
Also I would like to know how to use OR in an if icon i.e is this right: -

decision - a=b OR c=5

Ondra

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: IF Statement help

Post by Steve »

bitwise operators:

0x31 AND 0x25 = 0x21
0x31 OR 0x25 = 0x35

For "logical" operations (e.g. "if someting is true and something else is true"), you need to use "&&" and "||":

if (a = 5) && (b = 3)
if (a = b) || (c = 5)

In this code, "false" is zero and "true" is non-zero. So, if a was equal to 5, "a=5" would equal 1. If a was 6 or 7, "a=5" would equate to zero.

Why don't you experiment with the simulation. That will help you understand how things work. Also, I'm sure there have been other posts about this subject in the past.

Post Reply