Access Array Elements by Arrays Reference 
Author Message
 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



Sat, 17 Sep 2005 23:16:52 GMT  
 Access Array Elements by Arrays Reference
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...



Sun, 18 Sep 2005 05:06:33 GMT  
 Access Array Elements by Arrays Reference
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.



Sun, 18 Sep 2005 05:15:22 GMT  
 Access Array Elements by Arrays Reference
Thanks for your Help,

I was blindly irnoring this method.
Now It works!



Sun, 18 Sep 2005 17:35:10 GMT  
 Access Array Elements by Arrays Reference
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.



Sun, 18 Sep 2005 18:45:13 GMT  
 Access Array Elements by Arrays Reference
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...


Sun, 18 Sep 2005 22:05:45 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. HOWTO: reference elements of an array if array name is in a variable

2. access type referencing nested array element

3. Shifting array element & regex on array element

4. Arrays: Build array in multiple for loops or replace array elements

5. Passing array elements by reference

6. for every element of array find bounds in another array

7. Array and creation of the elements of the array

8. Adjustable array dimensions specified via array element?

9. creation of array elements and write traces on an array

10. selecting array elements with a logical array

11. (typep (make-array 10 :element-type 'bit) '(array bit (10)))

12. Do array element traces affect the whole array?

 

 
Powered by phpBB® Forum Software