Attempt to index global error

I’m new to Lua/Corona and need some assistance. Can someone explain why code snippit 1 but not code snippit 2 generates the following error:
main.lua:21: attempt to index global ‘myButton’ (a nil value)
–Code snippit 1
local button = {myButton,“button1.png”,80,190}
– Format of the table above is button name, image filename, x coordinate, y coordinate

—[[
for i = 1,1 do
b=button[i]
f=button[i+1]
x=button[i+2]
y=button[i+3]
b = display.newImage(f)
b.x=x
b.y=y
end
–]]

–[[
local myButton =

display.newImage( “button1.png” )
myButton.x = 80
myButton.y = 190
–]]

function myButton:tap(event)
p=p+1
return true
end

myButton:addEventListener(“tap”,myButton)


–Code snippit 2
local button = {myButton,“button1.png”,80,190}
– Format of the table above is button name, image filename, x coordinate, y coordinate

–[[
for i = 1,1 do
b=button[i]
f=button[i+1]
x=button[i+2]
y=button[i+3]
b = display.newImage(f)
b.x=x
b.y=y
end
–]]

—[[
local myButton = display.newImage( “button1.png” )
myButton.x = 80
myButton.y = 190
–]]

function myButton:tap(event)
p=p+1
return true
end

myButton:addEventListener(“tap”,myButton) [import]uid: 3388 topic_id: 247 reply_id: 300247[/import]

In the first snippit, the line where “myButton” gets created is commented out.

Also note that in both snippits, in the first line:

local button = {myButton,“button1.png”,80,190}

‘myButton’ does not exist yet, so ‘nil’ is being placed in the table.

HTH [import]uid: 1581 topic_id: 247 reply_id: 311[/import]

then how to overcome that error …please help me in this regard [import]uid: 52984 topic_id: 247 reply_id: 33071[/import]