Widget Table Test

I tested the widget “Table” but it seems have many troubles.
The big problem is that i can’t read every line of it:

  • put the line 1 of widget “Table” into tData => is OK
  • but put line 2 of widget “Table” into tData => return an empty value

Other problem is that i can’t set text of it to a multidimension (row and col) array
I don’t know if is a bug or a my error but it seems the widget is wrong and obviously without a minimal documentation is impossible for me find an answer.

You can access the tableText of widget “table”

put the tableText of widget "table" into tData
put line 5 of tData into tLine
set the text of widget "myInput" to tLine

this is for a single column text in widget “table”

To access the same line via array:

put the dataArray of widget "table" into tDataArray
put the number of lines of the keys of tDataArray into tNumLines
put tDataArray[5]["col 1"] into tLine5
set the text of widget "myInput" to tLine5

The dataArray was auto generated when I set the tableText to a list of lines.
Note that in this example the number of lines of the keys of tDataArray are not used but show how to get at the number of elements of the array.

To set the data of the table widget I used this for a two column data set

put the colorNames into tColorNames
put line 1 to 10 of tColorNames into tCol1Names
put line 1 to 10 of tColorNames into tCol1Names
repeat with i = 1 to 10
   put line i of tCol1Names & tab & line i of tCol2Names & cr after tCollect
end repeat
delete char -1 of tCollect -- last char is a return
set the tableText of widget "table" to tCollect

Using an array to populate widget table

Again 2 columns same as above using tab delimited data

put the colorNames into tColorNames
put line 1 to 10 of tColorNames into tColum1Data
put line 11 to 20 of tColorNames into tColum2Data
repeat with i = 1 to 10
   put line i of tColum1Data into tArrayData[i]["col 1"]
   put line i of tColum2Data into tArrayData[i]["col 2"]
end repeat
set the dataArray of widget "table" to tArrayData

To clear the widget “table”

set the tableText of widget "Table" to ""

Very good Bernd. Your help was precious. Now i want to use table rather than dropdown to create a combobox that is missing. Now i i ask you another effort to help me, can you explain something similar to table for a mysql database connection/list record/update and write recod? Sorry but looking into LC documentation for me is not clear.
Thank you again

Sorry, but I have no experience using mysql.

Maybe this helps:
https://lessons.livecode.com/searches?text=sql&commit=Search

I don’t understand what is wrong.

  1. I move a widget table on card
  2. i want to edit table columns so i use columns option in object inspector
  3. i need only 2 columns and i create them by inspector (i can’t change the colum label but this is a particular)
  4. when i go to card i see col 2 two times rather than col 1 and col 2

Since the table inspector is so sensitive can i set the table through code?