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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error: unbundle by name

Solved!
Go to solution

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

0 Kudos
Message 1 of 20
(3,709 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 20
(3,674 Views)

I was actually interested in those two errors which are shown. 

I attach the code (sorry about this).

Thanks a lot, 

0 Kudos
Message 3 of 20
(3,664 Views)

Hi Davide,

 

for references your should ALWAYS use shift registers in loops!

For error wires I often also use a shift register.

 

Try that on your own!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 20
(3,660 Views)

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!


GCentral
0 Kudos
Message 5 of 20
(3,620 Views)

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

0 Kudos
Message 6 of 20
(3,605 Views)
Solution
Accepted by topic author DavideB

@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 😉


GCentral
Message 7 of 20
(3,599 Views)

@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.

 

  • Also the file refnum belongs in a shift register. It should never be turned into an array. You have one file!
  • What is a "machine" in this context?
  • "Merge errors" is NOT what you want. There is no need to built an array of errors if you are only interested in the first one. Keep the data structures simple. You could terminate the inner FOR loop on error using a conditional terminal. What kind or errors do you expect at run time? Don't you want to e.g. handle the error of the file dialog is cancelled?
  • Your inner loop will not spin on first call, because your boolean shift register is not initialized causing it to start with an empty array. How big is the array you are reading? Can you explain what the code is supposed to do in simple terms? I am sure there is a much more elegant solution.
  • There is a "+1" primitive, no need for any orange. Get familiar with numeric representations.
  • The content of your inner case structure can be replaced by a single formatting statement.

 

0 Kudos
Message 8 of 20
(3,587 Views)

Now I got it! Thanks a lot cbutcher

0 Kudos
Message 9 of 20
(3,584 Views)

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).


GCentral
0 Kudos
Message 10 of 20
(3,579 Views)