LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access Array Elements by Arrays Reference

Hi there,

I'm currently working on a vi that writes clusters as recordsets into
specific tables in a database.
Due to this I have a problem filling an array of clusters equal to the
recordset structure of
a table. I wonder if it might be possible to access each element of an
array by using the arrays
reference instead of a local variable. At the moment I couldn't find any
properly working method for
that. Is anybody able to giv me some advice or hint?

Thanks a lot!

--
Sebastian Dau
0 Kudos
Message 1 of 6
(3,666 Views)
If I understand you, you want to update the value of an array using a property node. If this is correct, the answer to your question that yes you can do this, but it would be a VERY bad idea.

First, accessing a control or indicator in this way is very very inefficient.

Second, because you are wanting to update an array, your code is going to have to read in the existing array, modify it and then write it back. This situation is a race condition waiting to happen...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 6
(3,666 Views)
Hi,
If I've understood you correctly you are trying to access array data using Reference of array element.
If so you have to follow the next steps:

1. Right click on the Reference of you array on the diagram and select "Create->Property->Value" from pop-up menu.The property node will appear.
2. Wire the Reference to the input of property node.
3. This property allows you to read or write data from/to your array depending on its mode. If you right-click on the property node you can change it to write or read mode by selecting "Change to write/read" option from pop-up menu.

Good luck.

Oleg Chutko.
0 Kudos
Message 3 of 6
(3,666 Views)
Thanks for your Help,

I was blindly irnoring this method.
Now It works!
0 Kudos
Message 4 of 6
(3,666 Views)
But actually Mike is right. This method gives the result but it uses more memory recourses indeed. Each call of Property node creates the copy of your object in memory.
Be careful.

Good luck.

Oleg Chutko.
0 Kudos
Message 5 of 6
(3,666 Views)
Sebastian; Be careful about thinking that you have solved your problem because a technique works--or appears to work. The method you are talking about uses excessive resources, is slow and inefficient and is an open source for race conditions. Right now the thing seems to work, what happens when you have other code executing at the same time, accessing the same data? Or say you install the code on a computer that's faster--or slower--than the one you're using now. Will it still work? If not will you be able to figure out why it suddenly stops working? Or why it only seems to work on certain computers? In terms of performance, you always have to go for the best performance you can because you never know how you will want to use the code in
the future. In other words, you use this VI in one place and you can't notice the performance difference. But what happens when you use this VI in a 100 places in your code? Will the performance loss still be unnoticeable? Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 6
(3,666 Views)