09-16-2010 08:01 PM
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.
09-17-2010 01:54 AM
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
09-17-2010 03:43 AM - edited 09-17-2010 03:44 AM
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.
09-17-2010 10:13 AM
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.
09-17-2010 12:06 PM
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.