From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Putting string value into a table

Solved!
Go to solution

Hi,

 

Probably an easy question, but I'm reading data from a RFID reader which returns a string value of 12 bytes. Everytime an RFID is read, I want the tag string to be inserted into a table on the front panel. So basically a log of the each tag [Read -> Insert to row 0] then [Read -> Insert to row 1] and so on. I have the RFID reader working, I just don't know how to put the string into the table.

 Capture.JPG

 

I'm not sure of the steps needed to reach the table control (or if table control is the right thing to use).

 

Any help would be greatly appreciated. Thanks.

0 Kudos
Message 1 of 14
(4,058 Views)

Its just a 2D Array of string. Use array functions to manipulate it.

 

Spoiler
Table.png

CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 14
(4,039 Views)

But I don't have a 2D array of string to manipulate. The RFID reader returns a scalar string value (leaving the VISA read into the case structure). Do I have to build a 2D array with the scalar string values? So the question is probably, how do I create a 2D array with scalar string values.

0 Kudos
Message 3 of 14
(4,015 Views)

Hi CJBee,
-Table Control/Indicator is 2d array.
-The number of elements in the array needs to be initialized at first.For this just create an 2d array of string constants and connect it to table control.
-Then you can enter/insert your value into the 2d array(Table Control) using appropriate row and index.

-Please find the image shown below for more detail. It's similar to as .aCe. mentioned. Instead of using two times Replace array, you can use in for loop and index the values appropriately.

Thanks
uday
0 Kudos
Message 4 of 14
(4,001 Views)

If you don't have multiple elements to display, then you can simply show the scalars in a string indicator. Use Concantanate String and append the new value plus an end of line constant. Use a shift register to keep the string.

0 Kudos
Message 5 of 14
(3,992 Views)

Ok. So i've initialised my array outside of the loops, as that only needs to happen once. Then inside the when true case structure, i have added a for loop to replace array at the index dependent upon the for loop count. However i'm getting a broken wire saying they are of different array dimensions, and ii'm unsure as to why.

Pic attached.

0 Kudos
Message 6 of 14
(3,979 Views)

That code makes no sense. What is the purpose of running the for loop ten times when you have a single scalar? Don't you understand the auto-indexing feature of a for loop? You should be able to see that you are passing a 1D array to the index array function. Even using the Replace Array Element makes little sense.

0 Kudos
Message 7 of 14
(3,974 Views)

Yeah i gathered that quickly after I posted. Sorry. All i want is to insert a read string, into the first row of an array, which is then presented in a table. When another tag is read, I want that to be inserted into the second row of the array, and then presented in the table. And so on. Do I use a for loop to determine the row at which the string is inserted?

0 Kudos
Message 8 of 14
(3,956 Views)

@CJBee wrote:

Ok. So i've initialised my array outside of the loops, as that only needs to happen once. Then inside the when true case structure, i have added a for loop to replace array at the index dependent upon the for loop count. However i'm getting a broken wire saying they are of different array dimensions, and ii'm unsure as to why.

Pic attached.


Your inner loop will iterate twice due to autoindexing and you only have a 1D array because of that: Incompatible with the table datatype.

 

Since you want to continually insert new rows with every reading, you cannot preallocate the array. The final size is not known.

Simply keep the 2D string array in a shift register of the outer while loop, then use "built array" to append new rows to the array. (Insert another "build array" right after the reading to turn it into a 1D array with one element before appending it as a new row.)

Message 9 of 14
(3,950 Views)

No. If you use the build array, it will automatically append at the end. I still don't understand why you insist on using a 2D array indicator instead of a simple string indicator or even a listbox which would be a 1D array.

0 Kudos
Message 10 of 14
(3,944 Views)