LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array in for loop

Solved!
Go to solution

Hello and thanks for reading.

 

I have a c++ program that I use to list CCD-cameras available on computers in a LAN. For this I have constructed a VI, lets call it List.VI, that I provide a string containing the computer name. The return is a list of the cameras available on the computer specified.

 

Now I want to use this VI to scan several computers and store the return in an array where each element represents the return from one computer. I don't know how many computers I'm going to use so the size of the return is specified by the number of elements in the input array. The VI I'm supplying isn't functional on other computers but it will give you an idea on what I'm aiming for.

 

I have incorporated my List.VI in a for loop and it generates 3 return messages (in my example code). My problem is the Replace Array Subset function. It requires an text control array (which I call dummy array) in which I'm suppose to replace one element which works fine for one loop. But when the loop iterates and the second return from List.VI is placed in the second element of the dummy array but the first element is lost. I need to find a way of either stacking the return elements or somehow update the already returned elements in the dummy array before filling the next. And I can't do it with any of the functions available. Are there any other functions of program designs that can help me?

 

Any tips would be much appreciated.

 

Best regards

/Mikael

0 Kudos
Message 1 of 7
(2,675 Views)
Solution
Accepted by topic author Mikael.Peterson

You have some misconceptions here. Why so complicated? All you need is an autoindexing FOR loop.

 

 

(In the more general case, you would need to built your array in a shift register, but not here. You also cannot replace an element that does not exist)

Message 2 of 7
(2,670 Views)

Thank you!

 

I didn't know about autoindexing for loops.

0 Kudos
Message 3 of 7
(2,630 Views)

Thanks again for the quick response and the nice answer, but I have another question.

 

Autoindexing FOR loops executes sequentially, but what if I want to run an user defined number of calculations in parallel? Or more specific; if I want to use parallel instances of system exec.vi? Is there a structure that does this?

 

Best regards

 

/Mikael

0 Kudos
Message 4 of 7
(2,605 Views)

You can use VI server with Dont wait for completion to start parallell processess. I take it you can use that to start 10 SystemExec.vi. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 7
(2,599 Views)

 


@Mikael.Peterson wrote:

 

Autoindexing FOR loops executes sequentially, but what if I want to run an user defined number of calculations in parallel? 


 

In newer labview versions, you can enable parallelism if there is no data dependency between loop iterations. This allows several iterations of the for loop to execute concurrently.

 

Details.

Message 6 of 7
(2,589 Views)

Thank you! Thats exactly what I wanted.

0 Kudos
Message 7 of 7
(2,559 Views)