12-05-2013 08:37 AM
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.
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.
Solved! Go to Solution.
12-05-2013 08:49 AM - edited 12-05-2013 08:49 AM
Its just a 2D Array of string. Use array functions to manipulate it.
12-05-2013 01:08 PM
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.
12-05-2013 01:57 PM
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.
12-05-2013 02:49 PM
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.
12-05-2013 04:13 PM
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.
12-05-2013 04:23 PM
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.
12-05-2013 05:03 PM
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?
12-05-2013 05:08 PM - edited 12-05-2013 06:19 PM
@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.)
12-05-2013 05:16 PM
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.