LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how force labview to execute loops sequentially ?

i have some "for loops" and another part of my vi (normally) waits for the end of these "for" loops; but this part always begins before the start of the loops, and LabView returns an error.
I tried to chain parts with booleans, but it didn't work...

did someone has an idea ?

thanx

Matt
0 Kudos
Message 1 of 7
(4,719 Views)
LabVIEW is a dataflow language. Unless there is data connecting functions or structures, the LabVIEW compiler will run those in parallel. Placing something on the right side of the diagram does nothing for dataflow and will not affect execution order. A great way to enforce execution order is to use the error in/out clusters that most functions have. If you don't have them in the code you wrote, add them. You can have an error out in one for loop wired to an error in of another, etc. until the last for loop's error out is wired to an error in to your other code. Or, multiple error outs can be wired to Merge Errors.vi and this output can be wired to your other code.

You can also cheat a little and use the sequence structure. Howver, if you have correct d
ataflow, there is no need for a sequence.
0 Kudos
Message 2 of 7
(4,719 Views)
Matt
this sounds like a dataflow situation.... i have attached a very simple example of how dataflow works. Dataflow is something very integral to LV. basically a loop or node will not execute until it has valid data on all inputs...

Dan
Message 3 of 7
(4,719 Views)
You must not have your boolean chain setup correctly, or it would be working.

Look at the attached image. Using the booleans for dataflow, "For Loop 1" and "For Loop 2" will run in parallel, the "While Loop" will have to wait until both of the For loops have completed executing and has received the booleans from the "For" loops before it can can start executing.

Check the dataflow you have setup to make sure it's a complete chain. If you still can't figure it out, give us some more details or post your code, or a snippit of it here so we can see what's going on.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 4 of 7
(4,719 Views)
there is a more precise description of my vi:
1- list all files of 1 directory
2- for each file found, read data and do some conditional calculations, then add data to an array
3- when all files are read and computed, export this result array to a file.

the problem is: the directory path for output depends on calculation, so i create it in the "for" loop. Then i export this path from loop with a property node. This property node is used later as input of "write characters to file.vi".
And Labview tries to execute this before the "for" loop, and displays a file selection window, which should not be.
0 Kudos
Message 5 of 7
(4,719 Views)
Mc wrote:
> there is a more precise description of my vi:
> 1- list all files of 1 directory
> 2- for each file found, read data and do some conditional
> calculations, then add data to an array
> 3- when all files are read and computed, export this result array to a
> file.
>
> the problem is: the directory path for output depends on calculation,
> so i create it in the "for" loop. Then i export this path from loop
> with a property node. This property node is used later as input of
> "write characters to file.vi".
> And Labview tries to execute this before the "for" loop, and displays
> a file selection window, which should not be.

Why are you using a property node instead of just wiring the data?

If you can't avoid this, try the "queue"
(under advanced, syncronizing,
queue). Here you can create a queue, put the data in in one loop, and
let the read-command wait unthil there is any data in the queue.

I think if you put up an (possibly stripped down) example of your code,
someone could help to solve this in a clean way.

Bye

Marco
0 Kudos
Message 6 of 7
(4,719 Views)
Thanx Ed for your help and your .gif which really helps me... I soluced my problem with the option "disable indexation" of FOR loop outputs... Very simple, but hidden for beginners 😉

Thanx all for helping.

Matt
0 Kudos
Message 7 of 7
(4,719 Views)