WMassey Posted November 2, 2005 Report Share Posted November 2, 2005 OK, I'm fixing to show my ignorance here Quote Link to comment
David Wisti Posted November 3, 2005 Report Share Posted November 3, 2005 It could be done by reference like this example. Download File:post-319-1131030516.vi Quote Link to comment
WMassey Posted November 3, 2005 Author Report Share Posted November 3, 2005 It could be done by reference like this example. Yes, I even considered that once as well. But that, like everything else I have thought of so far, is not a one-box-contains-everything solution. You still need at least one additional external step (in this case, pulling out the array reference) before calling the subVI. If I'm willing to allow one additional external step then I can easily do it very simply with variants. I just thought that, since this seemed like such an obvious thing to routinely do, there should be some universally-polymorphic LabVIEW primative to do it. Followup: OK, I'm going to have to retract those last two sentences. It's not so easy with variants. I tried it here: and anytime the initial array size value isn't large enough to include the "Index" value I get an "Error 91 occurred at Variant To Data - The data type of the variant is not compatible with the data type wired to the type input." Quote Link to comment
Michael Aivaliotis Posted November 3, 2005 Report Share Posted November 3, 2005 One way to simplify your code would be to use the reshape array function. See attached image. You still need to check if the index goes beyond the original array size but this method is more efficient. Quote Link to comment
WMassey Posted November 3, 2005 Author Report Share Posted November 3, 2005 One way to simplify your code would be to use the reshape array function. See attached image. You still need to check if the index goes beyond the original array size but this method is more efficient. Hey, that is better! :thumbup: Thanks! P.S. I've attached a polymorphic (for the common data types) version of this VI. It still won't do arbitrary cluster data, but it is easy enough to paste TypDef'd controls into its front panel to generate new VI's to handle those data types. I'm just really surprised that this isn't built in by NI somewhere. Download File:post-2800-1131058454.zip Quote Link to comment
BChandler Posted November 5, 2005 Report Share Posted November 5, 2005 built in by NI somewhere. It is sort of: See attached vi for a completly polymorphic version that can easily be expaned to multi-dimensional arrays. Uses a reference to the array's element. But indexing is clumsy, so maybe room for improvment. Interesting problem. I've never had a use for this operation before. I can usally make an array with the maximum expected elements first. -WDC Download File:post-2910-1131208048.llb Quote Link to comment
WMassey Posted November 5, 2005 Author Report Share Posted November 5, 2005 It is sort of: See attached vi for a completly polymorphic versionthat can easily be expaned to multi-dimensional arrays. Uses a reference to the array's element. But indexing is clumsy, so maybe room for improvment. Interesting problem. I've never had a use for this operation before. I can usally make an array with the maximum expected elements first. -WDC Wow, interesting approach, though somewhat out of left field. I'm now sure how efficient it would be or is there is a way to make it work without the upper-level VI having a control/indicator for it to operate on but I'll give you points for creativity. I find I use this operation most often when dealing with instrument/system configuration data that a user is saving to a file devoted to storage of similar data. I have no idea at the outset how many various setups a user might eventually use or want to keep so I have to allow it to dynamically grow. In some cases there is even an advantage to letting the user pick the index which the setting is saved under. I just learned early on that the "insert into array" primitive didn't behave like I thought it should if it was given an index a bit beyond the bounds of the incoming array. Heck, it didn't even return an error. Thanks for the reply. It was interesting. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.