pawhan11 Posted January 24, 2021 Report Share Posted January 24, 2021 I am looking for a way to do convert N dimensional array to 1d array of variants. Can this be done using native labview functions (some hidden gems etc), without using OpenG? Another issue is with maps and sets, i want to get data out as array of variants, having set or map as variant. Quote Link to comment
pawhan11 Posted January 24, 2021 Author Report Share Posted January 24, 2021 (edited) For arrays i came up with this, dimensions are handled up to 10 For maps and sets it seems there is no way to cast them to variant arrays... Edit. I am lost now, according to my logic 2 on the bottom should be possible: Edited January 24, 2021 by pawhan11 Quote Link to comment
ShaunR Posted January 24, 2021 Report Share Posted January 24, 2021 (edited) I don't have access LV2020 right now for sets but I maybe have a solution for the arrays which should be much faster and accommodate any number of dimensions, Edited January 24, 2021 by ShaunR Quote Link to comment
pawhan11 Posted January 24, 2021 Author Report Share Posted January 24, 2021 Nice, but I require the input to be variant, not an array. Quote Link to comment
ShaunR Posted January 25, 2021 Report Share Posted January 25, 2021 (edited) 20 hours ago, pawhan11 said: I am looking for a way to do convert N dimensional array to 1d array of variants. 18 hours ago, pawhan11 said: For arrays i came up with this, dimensions are handled up to 10 14 hours ago, pawhan11 said: Nice, but I require the input to be variant, not an array. ¯\_(ツ)_/¯ Edited January 25, 2021 by ShaunR 1 Quote Link to comment
pawhan11 Posted January 26, 2021 Author Report Share Posted January 26, 2021 @ShaunR I might have formulated question incorrectly 😁 I want 3 separate functions that have: - variant input and return 1d array of variants when input variant is array (any dimension any data type in array) - variant input and return array of variants when input variant is set (any data type in set) -variant input and return variant pairs of key values when input is Map (any data type of key and value in map) For Maps and Sets I can get type info using Type Parsing Library but not the actual, the only way i see is digging into type descriptors... Quote Link to comment
Paul Davey Posted January 27, 2021 Report Share Posted January 27, 2021 Why not use ShaunR's solution as a Malleable VI? 1 Quote Link to comment
LogMAN Posted January 30, 2021 Report Share Posted January 30, 2021 (edited) On 1/26/2021 at 2:39 PM, pawhan11 said: - variant input and return 1d array of variants when input variant is array (any dimension any data type in array) There is a VI in OpenG LabVIEW Data Library that does this for you. On 1/26/2021 at 2:39 PM, pawhan11 said: - variant input and return array of variants when input variant is set (any data type in set) -variant input and return variant pairs of key values when input is Map (any data type of key and value in map) For Maps and Sets I can get type info using Type Parsing Library but not the actual, the only way i see is digging into type descriptors... I took this as a challenge and added two VIs to my library on GitHub - https://github.com/LogMANOriginal/LabVIEW-Composition Decompose Map extracts variant keys and values of variant maps Decompose Set extracts variant elements of variant sets I have successfully tested these VIs with various different types, but there could still be bugs. Let me know if you find anything. I strongly discourage using these in production! Edited January 30, 2021 by LogMAN Fix image scaling 1 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.