06-23-2011 04:26 AM
Hi all,
I have a for loop inside a while loop. All the main functions are running in this while loop. However, once the for loop is running other functions in the while loop don't run anymore until the for loop stop running. Could someone help me with this problem? Thank you.
Regards,
Nicky
Solved! Go to Solution.
06-23-2011 04:31 AM - edited 06-23-2011 04:36 AM
Hi Nicky,
I have seen another similar post this morning. This is happening because you are running the for loop inside the main while loop. So the while loop has to wait for the for loop to complete its run to take its next itration. Its better to run two parallel while loops and inserting your for loop in the secondary while loop and calling it from the main while loop. you may refer to the 8th and 9th post on this link. Also check the attached vi.
Regards,
Nitzz
(Give Kudos to Good Answers and Mark it as a solution if your problem is Solved;))
06-23-2011 05:05 AM
Thanks Nitzz. it seems to be a good solution. But I am still wondering if I can control the for loop to stop running from first while loop. here i attached a example vi.
Regards,
Nicky
06-23-2011 05:16 AM
Hi Nicky,
Did you mean stopping the Second while loop from first??? Because stopping the for loop depends on the Loop Count (N) terminal of the for loop. Did you check the attachment in the above post?
Regards,
Nitzz
(Give Kudos to Good Answers and Mark it as a solution if your problem is Solved)
06-23-2011 06:28 AM - edited 06-23-2011 06:29 AM
Hi Nitzz,
I checked the vi you posted. I was just wondering if there is another way to stop the for loop.
Regards,
Nicky
06-23-2011 07:02 AM
Hi Nicky,
Ah, well i don't have much suggestions but may be you can try with a conditional for loop. I have attached an example. You can go through it. I don't know whether this is a good idea to use it this way but still if it helps you, then I'm glad.
To create a condtional for loop, place a normal for loop on the block diagram , right click it and select condtional terminal.
Regards,
Nitzz
(Give Kudos to good Answers and Mark it as a Solution if your problem is Solved;))
06-23-2011 07:21 AM
Thanks Nitzz. It really helps.
06-23-2011 08:24 AM
@Nicky87 wrote:
I have a for loop inside a while loop. All the main functions are running in this while loop. However, once the for loop is running other functions in the while loop don't run anymore until the for loop stop running. Could someone help me with this problem? Thank you.
That's the expected behaviour. Each cycle of the While loop waits until all included functions are finished.
/Y