Table, Array help

Hi. I have this table/array

I got inspiration from: https://coronalabs.com/blog/2011/06/21/understanding-lua-tables-in-corona-sdk/

But I keep getting an error: Main.lua:17 ‘=’ expected near ‘textString’

line 17 is about text 3 or 4. 

I tried different ways from the inspirationssite, but I keep getting the error.

Local textString = {

[1] = “text 1”

[2] = “text 2”

[3] = “text 3”

[4] = “text 4”

[5] = “text 5”

[6] = “text 6”

[7] = “text 7”

[8] = “text 8”

[9] = “text 9”

[10] = “text 10”

[11] = “text 11”

[12] = “text 12”

[13] = “text 13”

[14] = “text 14”

}

You forgot to put comma’s between the array items:

local textString = {    [1] = "text 1",     [2] = "text 2",     [3] = "text 3",     [4] = "text 4",     [5] = "text 5"     [6] = "text 6",     [7] = "text 7",     [8] = "text 8",     [9] = "text 9",     [10] = "text 10",     [11] = "text 11",     [12] = "text 12",     [13] = "text 13",     [14] = "text 14" }

Thanks @pouwelsjochem8 
I tried it several times with and without commas, but no difference… I copypasted your code and it worked. I have absolutely no idea why I couldnt get it to work… But thanks!!!

First the Local should be local. Case matters.

Next, if you want a numerically indexed array you can either do:

local textString = {} textString[1] = "text 1" textString[2] = "text 2" textString[3] = "text 3" textString[4] = "text 4" textString[5] = "text 5" textString[6] = "text 6" textString[7] = "text 7" textString[8] = "text 8" textString[9] = "text 9" textString[10] = "text 10" textString[11] = "text 11" textString[12] = "text 12" textString[13] = "text 13" textString[14] = "text 14"

or

local textString = { "text 1", "text 2", "text 3", "text 4", "text 5", "text 6", "text 7", "text 8", "text 9", "text 10", "text 11", "text 12", "text 13", "text 14" }

Thanks… that could be the reason why I could not get my own code to work

You forgot to put comma’s between the array items:

local textString = {    [1] = "text 1",     [2] = "text 2",     [3] = "text 3",     [4] = "text 4",     [5] = "text 5"     [6] = "text 6",     [7] = "text 7",     [8] = "text 8",     [9] = "text 9",     [10] = "text 10",     [11] = "text 11",     [12] = "text 12",     [13] = "text 13",     [14] = "text 14" }

Thanks @pouwelsjochem8 
I tried it several times with and without commas, but no difference… I copypasted your code and it worked. I have absolutely no idea why I couldnt get it to work… But thanks!!!

First the Local should be local. Case matters.

Next, if you want a numerically indexed array you can either do:

local textString = {} textString[1] = "text 1" textString[2] = "text 2" textString[3] = "text 3" textString[4] = "text 4" textString[5] = "text 5" textString[6] = "text 6" textString[7] = "text 7" textString[8] = "text 8" textString[9] = "text 9" textString[10] = "text 10" textString[11] = "text 11" textString[12] = "text 12" textString[13] = "text 13" textString[14] = "text 14"

or

local textString = { "text 1", "text 2", "text 3", "text 4", "text 5", "text 6", "text 7", "text 8", "text 9", "text 10", "text 11", "text 12", "text 13", "text 14" }

Thanks… that could be the reason why I could not get my own code to work