LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array pointer in array

Can anybody tell me how to create pointers in an array pointing to other arrays?
0 Kudos
Message 1 of 15
(4,616 Views)
Hello RichL,

what do you need pointers for?
But anyway: you can put references to array controls/indicators into an array.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(4,608 Views)
Hello GerdW,

in my system, there are an unknown number of sources and each source has an unknown number of channels. So first I read the sources and store them into an array. It seems to me the easiest to assign a pointer then for each source pointing to a new array where the channels, belonging to that source are stored. Then a GUI should be available for the user to select a source and, in a popup-menue, the corresponding channels. Then the user can select a channel and the data of this channel will be shown in a graph.

Did I express myself understandably? Would references solve this problem?

Kind regards
Richard
0 Kudos
Message 3 of 15
(4,585 Views)

A reference is like a pointer.  You just can't increment the reference like can increment a C pointer.  Create your arrays, create a reference node for each one, and put these into an array of references.  Then index the array to get reference to a regular array.  Use properties to manipulate array data.  See attached picture:

Message Edited by tbob on 12-14-2005 05:17 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 15
(4,583 Views)
Hi tbob,

thanks for your suggestion! I did build it up with three arrays and a numeric control to select one of the arrays, which works fine. However, there are the following effects which I don't understand yet.
1. The RefArray can only be defined as Variant, showing a violet colour instead of a green/blue as in your example; I could not find a refnumber without giving me an error.
2. By changing the array selector, following array elements are being written into: 1,1 of array0; 0,0 of array1 and 1,0 of array2. I don't see why it is different for each array. Is there a possibility to select the array element being written into?
My VI is attached, LV7.1

Kind regards
Richard

Message 5 of 15
(4,568 Views)
Hello RichL,

there are many threads on indexing array elements via references, just search for "array reference elements". It has to do with the index of the first displayed element...

Array values are given as variant when they are read/written by references. But you can convert to/from variant if needed. (Or do as tbob, just wire the proper type to the property node...)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 15
(4,559 Views)
Hello RichL,

a different way may be the usage of a 3D-array: x-dimension is source, y-dimension is channel, z-dimension is data value. Selection of data is easy: use array subset and wire x and y (source and channel)... Sideeffect: The array can get very big (memory inefficient) if one channel contains much more data than the other.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 15
(4,458 Views)
If all you're looking to do is generate a multi-dimensional array without forcing all single-dimension arrays to assume the same size (A real pain sometimes) then simply create an array of a cluster of an array.

You take a 1D array, bundle it (it's the only element in the cluster!), and then build an array of these clusters.  Voila, you have an (almost) 2-D Array which can contain rows (or columns, however you choose to look at it) of differing lengths.

See the following example:

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 8 of 15
(4,416 Views)


@RichL wrote:
Hi tbob,

thanks for your suggestion! I did build it up with three arrays and a numeric control to select one of the arrays, which works fine. However, there are the following effects which I don't understand yet.
1. The RefArray can only be defined as Variant, showing a violet colour instead of a green/blue as in your example; I could not find a refnumber without giving me an error.
2. By changing the array selector, following array elements are being written into: 1,1 of array0; 0,0 of array1 and 1,0 of array2. I don't see why it is different for each array. Is there a possibility to select the array element being written into?
My VI is attached, LV7.1

Kind regards
Richard




Strange, when I created my vi, the RefArray was blue-green, not a Variant.  On the front panel I placed a blank array.  Then I placed a Control Refnum into the array.  Now the array is defined as a Control Refnum Array, not a Variant.
Attached is a vi similar to the picture I had previously attached.  In your case, you would need a slightly different method because of your unknown quantities of channels for each source.  The use would select a source, and then you would have to retrieve an array of channels for that source.  The user then selects a channel, and you would have to retrieve the data for that channel.
Post what you have so far so that we can look at it.
 
- tbob

Inventor of the WORM Global
Message 9 of 15
(4,532 Views)
Hi GerdW,

I was thinking about this right at the beginning, but each source and each channel has more information attached to it such that the dimension would be far more than 3.  I think array references is the way to go.

Kind regards
Richard

0 Kudos
Message 10 of 15
(4,380 Views)