From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-30-2019 04:41 AM
I inserted a for loop inside a while loop. As a consequence I get an "unbundle by name" error when I try to connect the error out wire and the refnum wire outside of the while loop. I attach the code. Can you suggest me any workaround for this? Thanks
Solved! Go to Solution.
09-30-2019 05:46 AM - edited 09-30-2019 05:47 AM
Hi Davide,
I inserted a for loop inside a while loop. As a consequence I get an "unbundle by name" error when I try to connect the error out wire and the refnum wire outside of the while loop.
There are 3 errors listed in the error dialog, but only two of them are visible in your image…
After going through those "Training resources" offered in the header of the LabVIEW board you should have learned about "autoindexing" at loop borders and its consequences!
Read the LabVIEW help on loops and all those different tunnel modes!
I attach the code.
There is no code. Just a PNG image - which is hard to debug with LabVIEW!
09-30-2019 05:52 AM
I was actually interested in those two errors which are shown.
I attach the code (sorry about this).
Thanks a lot,
09-30-2019 06:05 AM
09-30-2019 09:54 AM
The other two errors are relating to different source and destination data types.
The source is an array of error clusters (from the autoindexing terminal) whilst the destination is just a normal error cluster.
Merge Errors can combine an array of error clusters into a single error cluster (the value will be the first error in the cluster, if one exists, or no error if not), but typically a Shift Register is used instead when going around a Loop (For or While).
The Unbundle by Name error comes from having an Unbundle by Name terminal with nothing connected to the input, left, side. That is, you disconnected the error wire!
09-30-2019 10:20 AM
Thanks cbutcher,
the merge errors solution is fine with me.
I still have to fix the other problem with refnum. I understand the difference in source and destination. I think I have to do something similar to what I did at the beginning when I used Reshape array to create more shorter arrays (one per machine) from a long one.
Would some sort of inverse reshape work here? (one long array from multiple short ones)
Thanks
09-30-2019 10:34 AM - edited 09-30-2019 10:36 AM
@DavideB wrote:
Thanks cbutcher,
the merge errors solution is fine with me.
I still have to fix the other problem with refnum. I understand the difference in source and destination. I think I have to do something similar to what I did at the beginning when I used Reshape array to create more shorter arrays (one per machine) from a long one.
Would some sort of inverse reshape work here? (one long array from multiple short ones)
Thanks
See GerdW's comment regarding references.
Essentially, each time you go around a Loop with an "auto-indexing tunnel", the value at the end of the iteration is placed in an array that becomes available when the loop finishes running. In this specific case, you're getting an array with N elements (one per iteration of the For loop) each of the same reference to a file.
You only want the one reference! Using a Shift Register changes this to "each iteration, use the value from the end of the previous iteration". Another working option is to use the "Last Value" tunnel method, but that has a specific problem with For loops - if the loop iterates 0 times, then the "last value" will be the default for that data type, which will not be a valid reference.
As GerdW said, when using references, you should use a Shift Register instead - this will ensure that even if the loop iterates 0 times, the value out will be the same as the value in.
During the loop iterations, the value of the reference won't change (unless you, e.g., close the file and open a new file, which you might consider in other cases like the file becoming large).
Edit - as a side comment, if you didn't already find this (I think you did, but writing anyway), you can change the terminal type by right clicking on it and choosing "Tunnel Mode" (to change the tunnel type) or "Replace with Shift Register" to do as you'd probably guess 😉
09-30-2019 10:57 AM
@DavideB wrote:
Thanks cbutcher,
the merge errors solution is fine with me.
I still have to fix the other problem with refnum. I understand the difference in source and destination. I think I have to do something similar to what I did at the beginning when I used Reshape array to create more shorter arrays (one per machine) from a long one.
Would some sort of inverse reshape work here? (one long array from multiple short ones)
Your VI is just buggier than a formicarium. 😮 and there are plenty of other problems.
09-30-2019 11:00 AM - edited 09-30-2019 11:01 AM
Now I got it! Thanks a lot cbutcher
09-30-2019 11:05 AM
Note that using Merge Errors after an indexing output on error clusters also suffers the same problem with 0-iteration loops - so a shift register is usually what you want there too.
Some exceptions are when you want either
a) the loop to go through all iterations regardless of errors in some iterations (particularly if parallelizing the loop, then you can't use a SR). Then you'll often use an array, possibly combined with Merging the Errors from before the loop (depending on desired input behaviour).
b) to perhaps count the number of errors after all iterations complete (I've never needed to do this).