LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing values to each array element individually

Hi,

 

Iam trying to write values to a 1- D array (string Indicator). Can any one tell me how I can write the values to the array using property node at different locations.

0 Kudos
Message 1 of 5
(13,386 Views)

Find an example in the attach.

 

Create indicator. Right-click on it at the Block Diagram > Create menu > Property Node > Value. Place property element to the BD, right-click on it and "Change To Write". Then pass any value you need to the array.

 

Hope that helps,

Max

0 Kudos
Message 2 of 5
(13,353 Views)

You can use the insert into array function with the input index and the new element and can use the Value property node to update that... One thing is if you want to add an element at 10th index atlease the 9th index should have contain some value.

 

Smiley Wink

-----

The best solution is the one you find it by yourself
0 Kudos
Message 3 of 5
(13,334 Views)

Hi maksya and Anand, thank you for replying my post, but actually I wanted to write the values to the array elements not at a time, but individually using Index value and property node.

 

such that I should have the flexibility to tell the index number to which the value should be written. And also the index number will not be in the serial order, it is randomly choosen. Suppose if the array consists of 5 elements, for the  first iteration I may write the value of 4th index element, next for 5th index element, next for 1st index element and so on. Can you please suggest me how to do this.

 

0 Kudos
Message 4 of 5
(13,308 Views)

You need to read the array, use Replace Array Subset to change the value, and then write the array back in.

 

But I would be very careful with all of this.  If you are using local variables and/or property nodes to access the value of an array, then you run the risk of race conditions where multiple locations could be stepping on each other trying to modify the data at the same time.

 

You would be better off maintaining a single wire in a shift register.  Or use a functional globabl variable to store the array, and have inputs besides get and set, that allow you to tell it what index you are setting.

Message 5 of 5
(13,294 Views)