Loops

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
Contact:

Loops

Post by ALAN_26 »

hello

I'm having a bit of a problem the loop dose not seem to work well .

example1 : loop while Variable = 10 ..............The loop ends imeditly !

example 2 : loop while varible1 = variable2 ......The loop ends imeditly !

example3 : loop while Variable < 10 .............. works fine !

example4 : loop while Variable > 10 .............. works fine !

can any one help please am i doing something wrong ?

Thanks in Advance

Regards Alan
Last edited by ALAN_26 on Fri Apr 20, 2007 7:47 pm, edited 1 time in total.

Chet
Posts: 61
Joined: Thu Oct 13, 2005 5:05 am
Location: USA
Has thanked: 2 times
Contact:

Post by Chet »

Testing the varible inside the loop, may work.

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

Post by ALAN_26 »

hello

Wath do you mean

i just made a simple program to test it loop while variable =10 and in the loop a calculation variable = varable +1 but it dose not work
The variable value is 1 and the loop ends !


This is from MM course :
The properties dialogue box shows you the options you have for controlling the loop. Next to the 'Loop while:' statement is the loop control text box. In this text box you put the loop condition: the loop will keep running until this condition is met. For example in this text box you could write:

count = 10 (Loop runs while variable count = 10) (not working)

count > 4 (Loop runs while variable count is greater than 4) (ok works)

count = preset (Loop runs while variable count is the same as variable reset) (not working)

Chet
Posts: 61
Joined: Thu Oct 13, 2005 5:05 am
Location: USA
Has thanked: 2 times
Contact:

Post by Chet »

I just looked at some code I've got and I actually test a input
varible. So it's really checking the state of a pin.

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

Post by ALAN_26 »

Hello

I'm not tying to test an I/O pin I'm just trying to loop untill a Specified value of the variable is meet, and i just cant do that whit a loop .

I know it can easly be done with an if and goto statments but with a loop it does not work !

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

The while loop will only work when then condition is true.

EG while var1 = 10 will run forever while var1 is equal to 10.

if var1 starts off at 1 then the while loop will never run because var1 does not equal 10.

You can make a while loop run a set number of times by double clicking the icon and selecting the loop count option.

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

Post by Steve »

If you have a while loop with the condition "count = 10" at the beginning of the loop, it will only enter the loop if the "count" variable equals 10. If "count" does not equal 10 before the loop command, then the loop will never be entered.

I think the statement "the loop will keep running until this condition is met" is not right and might be causing confusion. It should probably say "the loop will keep running while this condition is true".

Post Reply