11-14-2011 02:15 PM
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?
Solved! Go to Solution.
11-14-2011 02:18 PM
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
11-14-2011 02:23 PM
Thanks for the help and the tutorial!
11-14-2011 02:34 PM
Delete from array gives last element as default on one of the wires.
/Y
11-14-2011 03:20 PM
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"
11-14-2011 03:27 PM
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.
11-15-2011 01:59 PM
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.