Page 1 of 1

Accessing numerically indexd table inside a numerically indexed table

Posted: Thu Nov 22, 2018 11:27 pm
by zylesea
I am stuck in accessing content of a numerically indexed table within a numerically indexed table.

So far from the documentaion the case is clear with name indexed tables within a numerically indexed table

Code: Select all

buts = { {x1 = 0, y1 = 0, x2 = 100, y2 = 50},
            {x1 = 100, y1 = 0, x2 = 80, y2 = 50},
            {x1 = 180, y1 = 0, x2 = 100, y2 = 50} }

 For k = 0 To 2
          Debugprint (buts[k].x1, buts[k].y1, buts[k].x2, buts[k].y2)
  Next
But how to access the table's conent if the subtables are numerically indexed, too?

Code: Select all


buts = { { 0,  0,  100,  50},
            {100,  0, 80,  50},
            {180,  0, 100, 50} }

 For k = 0 To 2
          Debugprint (buts[k].[0], buts[k].1, buts[k] [2], buts.k[3])
  Next

All four versions written after Debugprint fail... The table gets initialized though, Listing content of buts shows their addresses, and I can even get the table lenght subtables with TableItems(buts[k]. But how to retrieve the actual content of these subtable fields?

Re: Accessing numerically indexd table inside a numerically indexed table

Posted: Fri Nov 23, 2018 1:29 am
by p-OS

Code: Select all

buts = { { 0,  0,  100,  50},
            {100,  0, 80,  50},
            {180,  0, 100, 50} }

 For k = 0 To 2
          DebugPrint (buts[k][0] .. " " .. buts[k][1] .. " " .. buts[k][2] .. " " .. buts[k][3]) 
 Next

Re: Accessing numerically indexd table inside a numerically indexed table

Posted: Fri Nov 23, 2018 9:05 pm
by zylesea
Hi p-OS, thanks for pointing me to the right syntax. I had tried that (see example) but must have done some typing/stupid other error because it failed before. With your confirmed syntax I tried once again and - hooray - it works.