LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write data to array of strings in cluster by reference

Solved!
Go to solution

Hi,

I have created a cluster that contains 4 arrays of strings and 2 boolean buttons.

I want to be able to write data in different elements of the string arrays but dont understand how.

I only manage to write data in the first element of the array. But i want to be able to reach all elements.

I want to write data by reference. 

Se attached VI for more info

WriteToArrayOfSTringsInCluster.png

 

Im sure someone has a nice solution.

0 Kudos
Message 1 of 20
(513 Views)

maxnoder1995_0-1765543135738.png

like this?

0 Kudos
Message 2 of 20
(501 Views)

Lets say i want to write data in array 1 at index 1 (10) and 3 (50)

How do i do that when using references?

 

tokar_0-1765544952108.png

 

0 Kudos
Message 3 of 20
(478 Views)

Hi tokar,

 

Would something like this be enough for your use ?

PinguX_0-1765546364748.png

 

Message 4 of 20
(464 Views)

Writing to an array element ...

paul_a_cardinale_0-1765581184275.png

 

Will only write to one element, and you usually don't know which one (it's whichever on last has text focus).

0 Kudos
Message 5 of 20
(433 Views)

I tried to implement your code but it seems like you dont use the same reference that i do, so i dont make it to work.

Perhaps you can implement your example into my code? Because i dont made it to work.

Code is in snippet, also attached as vi.

WriteToArrayOfSTringsInCluster_v2.png

0 Kudos
Message 6 of 20
(403 Views)

I dont understand your reference in the beginning, because i use a reference to a cluster that contains arrays of strings etc. When i wire that to proberty node and choose value as output i get variant and not 1D array of strings as in your example.....

 

 

 

tokar_0-1765636189263.png

 

0 Kudos
Message 7 of 20
(396 Views)
Solution
Accepted by topic author tokar

They used a strict reference, i.e. a reference that includes the type. Your typedef only has generic array references.

 

You can either use the generic reference and use variant to data

variant to datavariant to data

 

Or you can cast the refnum to a strict array reference. Create the type by right-clicking one of the string array references and selecting create>>constant.

strict array refnumstrict array refnum

 

In both cases, make sure to handle errors if the array is not actually a string array.

 

Insert into array will only insert one past the last element. So you cannot insert at index 2 into an empty array. To do that, you need to reshape the array first.

 

Message 8 of 20
(385 Views)

I tested but dosent work as you can see below.

 

 

 

WriteToArrayOfSTringsInCluster_v3.png

 

 

0 Kudos
Message 9 of 20
(370 Views)

Like I said, insert into array does not insert at index 2 into an empty array. Change the index to 0 or resize the array before inserting.

Also, show the scrollbar and scroll up.

Message 10 of 20
(363 Views)