Checking Variables

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

Moderator: Benj

Post Reply
User avatar
jollybv
Flowcode v5 User
Posts: 376
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times

Checking Variables

Post by jollybv »

Hi Guys

Not sure what is the correct way to do this. I have a variable called Key and a variable called Occupant now what i want is to say if key is > then 1 or key is < than (Occupant + 1) then proceed. I have tried the following key > 0 && Key < (Occupant + 1) key > 0 AND Key < (Occupant + 1) key > 0 OR Key < (Occupant + 1) but not sure which is the best way to do this

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Checking Variables

Post by medelec35 »

Hi Brian,
You will need to use two pipes (|| ) :
Pipe Key.png
(5.48 KiB) Downloaded 2451 times
Which mean logical OR
So you use

Code: Select all

If: (Key >1) || (key < (Occupant + 1))
Best to separate expressions with brackets.

Note:

Code: Select all

|| = OR

Code: Select all

&& = AND 

Code: Select all

! - NOT
You may already know this, but you are able to your variables to the simulation debugger watch window ,so you can check everything is working as expected.

I have explained how to do that in FC6 here.
Its exactly the same method for Flowcode V7

Just curious, but that statement only be false when Key = 1 and Occupant = 0
Is that what you're after?

Martin
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 376
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times

Re: Checking Variables

Post by jollybv »

Hi Martian

Thanks for the replay what I'm looking for is if the variable is between 1 & whatever i set the Occupant variable

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Checking Variables

Post by medelec35 »

Hi Brian
jollybv wrote:if the variable is between 1 & whatever i set the Occupant variable
Sorry I was taking this as a literal expression :
jollybv wrote: if key is > then 1 or key is < than (Occupant + 1) then proceed.

All you need to do is use AND (&&) instead of OR.
So:

Code: Select all

(Key >= 1) && (key <= Occupant)
Martin
Martin

User avatar
jollybv
Flowcode v5 User
Posts: 376
Joined: Thu Feb 12, 2009 5:20 am
Location: Cape Town
Has thanked: 81 times
Been thanked: 25 times

Re: Checking Variables

Post by jollybv »

Hi Martin

Thanks again yes that makes sens to me now

Post Reply