LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting elements of an array using property nodes

Johan,

It is interesting, but I just ran into what I think is a similar problem to yours, sort of...

I need to get ANY data from a cluster, and convert it to a string to write to a file. My program has no idea what the data is. It could be a string, a numeric, an array, whatever. Strings were of course no problem. Converting booleans was a little tricky, as was numerics. But now I have come across an array. The Variant returns something resembling the dimensions of the array. What I am planning to do is act upon this (I get a variant that contains "[nXn]" in it, so I can tell when it is an array) information to put the code into a mode where it can get the array data and then write it to a string.

This is going to be very difficult. What I wil
l more than likely do is just grab a reference to the array, and retrieve the value. Then, I can figure out the dimensions, and write the array as a single string, separated by commas, with the dimensions of the array at the start of the string.

As it has been suggested, this is probably how you should be going as well. The only way you can get to an element of an array is to get the array itself. Arrays in LabVIEW are stored as pointers, so trying to retrieve an element of an array through references seems impossible. Just grab the value of the reference "value" of the array, and index the array from there. I think your task is a lot easier than mine.

Also, if you go to LabVIEW help (not context help of course) from the "Variant to Data" function, you will see a link to an application note on Data Storage in LabVIEW that was included with your documentation. Read this document! It is extremely useful for what you are trying to do.
0 Kudos
Message 11 of 35
(2,847 Views)
Then again Labviewguru, take a look at the OpenG Toolkit packages! http://sf.net/projects/opengtoolkit
the lvdata package has VIs to manipulate variant data, the variantconfig has VIs to write clusters, arrays and variant data to INI files, and the string packages has a "Format Variant into String.vi".


LabVIEW, C'est LabVIEW

0 Kudos
Message 12 of 35
(2,847 Views)
Johan, have you tried my example? It does let you read the value without clicking the actual element.

I have also updated it slightly (see below) to convert the variant data to a numeric (you stated in your post that your array was of digital indicators). As you know what your data will be there should be no problem converting from variant data.

The array has also been 'covered' with a decoration to stop it being clicked in, and the Index value is now a numeric, rather than an array.

I hope this makes things a little more clear for you. Let me know if this is not the case and i'll be glad to help some more.

Kim
0 Kudos
Message 13 of 35
(2,819 Views)
Johan,
it seems that you are using a news server that filters out messages with attachments. Some replies to your question (Kim and mine) do have VIs attached to show how you can achieve what you want.
The group comp.lang.labview is available on newsgroups.ni.com with attachments and also mirrored on NI Developpers Exchange forums. Your thread is shown at (remove line breaks):
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000006E590000&USEARCHCONTEXT_CATEGORY_0=_49_%24_6_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0

Jean-Pierre


LabVIEW, C'est LabVIEW

0 Kudos
Message 14 of 35
(2,847 Views)
Jean-Pierre,

This is very usefull, in fact this is what I am looking for the first
time.
Except for the arrays, I assume I have to insert the Index Array.vi
into the variant config package to write clusters to ini files.

I wanted to do a similar thing by breaking down a cluster in its
separate objects and then determining the value and name of each
individual object.
It looks like you can only access the seperate elements of an array
when it is converted to an variant.
0 Kudos
Message 15 of 35
(3,127 Views)
LabviewGuru,

I have read that document. It is indeed very useful, but I wanted to
avoid the use of variant data. It feels more clean to go down to the
elements by use of references. I will try to do the trick you are
explaning but think that I'm still ending up with variant data.
If it still doesn't work out the way I want I think I will use the
tools Jean-Pierre Drolet suggested for manipulating variant data. He
has a solution for the problem I wanted to tackle.

Thanks anyway up till now, because it was very usefull.
0 Kudos
Message 16 of 35
(2,847 Views)
A bit off the topic, but - Open G had some useful functions, it was a bit of work to download and install though, it would be great if You made all the files available in one single download (could only find separate files for each function set, but maybe I was overlooking a bundle download). An installation set that put the tool as a top level "OpenG" button in the functions palette would also be great (regardless of the purpose of the installation...use or further development).
0 Kudos
Message 17 of 35
(2,847 Views)
Johan,

Why not get the value (, the entire array, ) from the property node "value"?
Then you can use Array Subset to get the required array values.

This does what the example in the pdf file does. You can also replace the
elements, and write back to the "value" property.

Reading from and writing to SelStart/SelSize doesn't seem to work for arrays
(it does for strings). That is, I never got it to work... Anyway, I'm not
even able to select elements, so why bother reading the selection?

Regards,

Wiebe.


"Johan" wrote in message
news:9abf782f.0208290638.44566d93@posting.google.com...
> I would like to know how I can access an array not by using the usual
> 'Index Array VI' but by using property nodes. I created an array with
> a dig
ital indicator and from this control a property node wich I set
> to Selection size[], Selection start[] and Value (Selsize[],
> selstart[], value). Changing the properties Selsize[] and selstart[]
> does not result in a visible change of the active element and changing
> the value property is not resulting in a change of the value of the
> active element.
>
> The reason of doing it this way is that I want to access elements of
> array that is referenced by the controls[] property of another control
> (cluster).
>
> Johan
0 Kudos
Message 18 of 35
(2,847 Views)
Just a little patience Mads... OpenG Toolkit is still under active development. There will be tools like package manager that will download all the required components directly in your LabVIEW directory with palettes and Tools menu.
Stay tuned for more features, I just hope you enjoy the currently released VIs even if the installation is still a little quirky.


LabVIEW, C'est LabVIEW

0 Kudos
Message 19 of 35
(2,847 Views)
Jean-Pierre, (from Johan now being Vlipje)

You still have a problem when the array is an array of clusters. Because of the variant it is impossible to get a reference to the actual cluster "elements".
I made a VI that makes clear where I want to go. I can resolve the elements of the inner cluster but can't access the individual values of of each control inside the inner cluster.

And this all has to be done without knowing what the actual structure of the cluster you want to read is.

Please look at the attached VI
0 Kudos
Message 20 of 35
(2,819 Views)