LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop creates 1-D array of data

Solved!
Go to solution

Hi, I'm building the circuit shown below and I'm running into a bunch of problems with the for loop creating a 1-D array of data of certain data types such as the ERROR OUT and VISA RESOURCE NAME. I understand why it is doing this but I only need the last value in the array (the value from the last iteration of the for loop). This applies for me for error out, visa resource name, and I was thinking about using the boolean that indicates when the for loop ends.

 

Is there any simple way to extract the last value in the 1-D array so that it is the correct type to be passed along the VISA and ERROR paths?

0 Kudos
Message 1 of 7
(3,109 Views)
Solution
Accepted by topic author JhonF

You are actually building a block diagram, not a circuit.  A circuit is an electrical system consisting of electrical wires and devices.

 

If you right click on the tunnel and pick Disable Indexing, then you will get the value of the last iteration rather than a 1-D array.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

Message 2 of 7
(3,104 Views)

Thanks for the help and the tutorial!

0 Kudos
Message 3 of 7
(3,100 Views)

Delete from array gives last element as default on one of the wires.

/Y 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 7
(3,098 Views)

More basically, turning off indexing at the tunnel gives just the last value.

 

Right click those little things on the right side of the loop and select "disable indexing"

0 Kudos
Message 5 of 7
(3,091 Views)

When using For loops any input that is a reference, VISA resource name or data that you care about should be wired to a shift register and not directly to the input node. If the loop does not execute (such as autoindexing an array with a length of 0) will result in the output value, even when wired through the loop, to be the default value of that data type. This is one of those little gotta's that can occur and are easily overlooked when trying to debug the issue.

 

Also, there is no reason to wire a Boolean out of the loop to indicate that it has completed. Any code that follows the loop that has an output wired to it will automatically wait to run until the loop is complete. This is the nature of dataflow programming.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 7
(3,086 Views)

Note that if the loop has zero iterations, output tunnels will give the default value for the data type.

This can be a problem if a for-loop is auto-indexed, and under certain circumstances the auto-indexing input happens to be an empty array.

0 Kudos
Message 7 of 7
(3,056 Views)