Passing specific values through different objects when clicked, aka calculator.

I’m searching all over the place for my specific problem and maybe it’s because I’m very new to all this that I can’t really see the solution. I’m trying to make a calculator the long way. Using images I’ve created as the numbered buttons. I’m trying to get it to where I can click on a numbered button and that number will show up on the screen. 

I’ve got it where it’ll show up in my terminal using print, but I just can’t figure out how to make it show up on my screen.

I’ll post the code below, and I’m sure I went the long way of creating a calculator, but I’m following a textbook. Any help would be awesome! and be gentle, I just started last week.

–code from top to bottom

display.setStatusBar(display.HiddenStatusBar)

w = display.contentWidth

h = display.contentHeight

local cal1 = display.newImage(“1.png”, w/2 - 240, h/2)

cal1.num = 1

local cal2 = display.newImage(“2.png”, w/2 - 120, h/2)

cal2.num = 2

local cal3 = display.newImage(“3.png”, w/2, h/2)

cal3.num = 3

local cal4 = display.newImage(“4.png”, w/2 - 240, 120 + h/2)

cal4.num = 4

local cal5 = display.newImage(“5.png”, w/2 - 120, 120 + h/2)

cal5.num = 5

local cal6 = display.newImage(“6.png”, w/2, 120 + h/2)

cal6.num = 6

local cal7 = display.newImage(“7.png”, w/2 - 240, 240 + h/2)

cal7.num = 7

local cal8 = display.newImage(“8.png”, w/2 - 120, 240 + h/2)

cal8.num = 8

local cal9 = display.newImage(“9.png”, w/2, 240 + h/2)

cal9.num = 9

local cal0 = display.newImage(“0.png”, w/2 - 240, 360 + h/2)

cal0.num = 0

local number = 0

textField = display.newText(number, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

function showNumber (event)

print(event.target.num)

textField:removeSelf()

textField = display.newText(cal1.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”,     90)

textField:removeSelf()

textField = display.newText(cal2.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal3.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal4.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal5.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal6.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal7.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal8.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal9.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

textField:removeSelf()

textField = display.newText(cal0.num, display.contentWidth/2, display.contentHeight/2 - 200, “Courier”, 90)

end

cal1:addEventListener(“tap”, showNumber)

cal2:addEventListener(“tap”, showNumber)

cal3:addEventListener(“tap”, showNumber)

cal4:addEventListener(“tap”, showNumber)

cal5:addEventListener(“tap”, showNumber)

cal6:addEventListener(“tap”, showNumber)

cal7:addEventListener(“tap”, showNumber)

cal8:addEventListener(“tap”, showNumber)

cal9:addEventListener(“tap”, showNumber)

cal0:addEventListener(“tap”, showNumber)

–end of code

Also if you find a better thread where this should be, let me know and I’ll post this there.