Bernd F Posted January 29, 2010 Report Share Posted January 29, 2010 Hy to @ll, i have the problem that i want to get the arraysize of a array i don't know the type of, because i only get the reference of a "TD1Hdl" (C-Type). So i cannot typecast the Array and use the "Array-size" block. I want to grap the reference of one by one element and put this reference to an other VI. alternative? I could pass a array of references, too. One reference per element. It would be more easy, but i didn't found something like "references to array elements[]". Thanks for your help. Bernd PS.: I just used the Array of string, to create a ref to an array. I don't know the type of it. Quote Link to comment
Grampa_of_Oliva_n_Eden Posted January 29, 2010 Report Share Posted January 29, 2010 This question sounds like you are on the path I was when I wrote this Nugget on the Dark-side (NI). http://forums.ni.com/ni/board/message?board.id=170&thread.id=267659&view=by_date_ascending&page=1 In that Nugget I shared the code to see how I did it (cludge!). I had to resort to flattning the array to a variant and get the size then poke at the control until I made it bigger, then I knew what the size was in one dimension.. lather rinse repeat for the next dimention. So the Correct answr (I believe) is you can not know without knowing the data type in the array, but the above Nugget does show "It can be done". One of the reasons i posted that Nugget was to try and find a better way by posting that redicuous approach in the hopes someone would show me the "right way". I suspect there is no "right way". Ben Quote Link to comment
Francois Normandin Posted January 29, 2010 Report Share Posted January 29, 2010 i have the problem that i want to get the arraysize of a array i don't know the type of, because i only get the reference of a "TD1Hdl" (C-Type). So i cannot typecast the Array and use the "Array-size" block. Hi Bernd, You can get the Array Size even if I don't know the array type by using the OpenG's "Array Size(s)" that you can find in the Variant palette. I want to grap the reference of one by one element and put this reference to an other VI. I don't think you can do that. You can get the reference to the array element (default value), but it's not the Elements References[] you're looking for. By looking at the class name of that default element reference, you can know what's the array datatype (or you can use OpenG's VIs again). While Ben's method (Nugget) works great with controls, it doesn't scale well with an array of unknown dimensions and sizes. Actually, sizes are not a problem... but dimensions are. If you restrict yourself to a 1D array (or a 2D array), then you can convert it but you'll have to work with Variant data, not references to individual elements. My advice would be to work with a variants in this case. It's heavier than carrying around the references, but overall it might be better to conserve dataflow in your program. Quote Link to comment
Bernd F Posted February 9, 2010 Author Report Share Posted February 9, 2010 Thanks. I found a very good example from shoneill at the nuggets. http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=267748#M267748 It's so easy. http://forums.ni.com/ni/attachments/ni/170/267748/1/Alternative%20Array%20size%20finder.vi 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.