cant figure out why

paul a paulite dot DE
is my email if you’re still interested [import]uid: 98393 topic_id: 30033 reply_id: 121143[/import]

Ok, lets speed things up. Replace your code with the following:

-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view  
   
 -- create a grey rectangle as the backdrop  
 local background = display.newRect( 0, 0, screenW, screenH )  
 background:setFillColor( 255 )  
  
   
 local font = "HelveticaNeue" or native.systemFont;  
   
 local label =display.newText("Tap here to send a text", 0, 0, font, 18) ;  
 label:setReferncePoint(display.CenterReferencePoint) ;  
 label:setTextColor(0, 0, 0) ;   
 label.x = \_W \* 0.5;  
 label.y = \_H - 50;  
   
 function label:tap(e)  
 native.showPopup("sms",{  
 body = "I sent this text from my app",  
 to = {5550000000} -- or "5550000000" if this doesn't work  
 }) ;  
 end  
   
 label:addEventListner("tap", label);  
 end  

[import]uid: 101952 topic_id: 30033 reply_id: 120452[/import]

One quibble that stood out as I skimmed:

[lua]local font = “HelveticaNeue” or native.systemFont;[/lua]

that always results in font = “HelveticaNeue” (which may not exist on the target device). [import]uid: 160496 topic_id: 30033 reply_id: 120454[/import]

I am very insterested in all help. But paul_g I have been sitting here trying to figure out how to send you the file based off paul a paulite dot DE. and I have no clue. [import]uid: 69302 topic_id: 30033 reply_id: 121148[/import]

That’s his e-mail address:

paul a paulite dot DE

substitute the " a " for “@” and the " dot " for a “.” leaving out the spaces.

Its the way people post their email addresses so spambots don’t pick them up. If he had typed it like:

spamme@mywebsite.de

then he opens himself up to excessive spam.

@Paul_G you should be able to grab the project from the dropbox link posted above. [import]uid: 19626 topic_id: 30033 reply_id: 121154[/import]

add [lua]return scene[/lua] at end of rob’s menu.lua

for me, everything is working [import]uid: 98393 topic_id: 30033 reply_id: 121170[/import]

BTW. This is a prime example of why indention of your code is important (when I say your, I’m not directing directly at you @babybeanie98, but for all newer programmers. Let me re-write this module for you with better indention and I’ll leave the error in so you can **see** it.

-----------------------------------------------------------------------------------------  
--  
 --level1.lua  
--  
-----------------------------------------------------------------------------------------  
   
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
   
-----------------------------------------------------------------------------------------  
-- BEGINNING OF YOUR IMPLEMENTATION  
--   
-- NOTE: Code outside of listener functions (below) will only be executed once,  
-- unless storyboard.removeScene() is called.  
--   
-----------------------------------------------------------------------------------------  
   
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view  
   
 -- create a grey rectangle as the backdrop  
 local background = display.newRect( 0, 0, screenW, screenH )  
 background:setFillColor( 255 )  
  
   
 local font = "HelveticaNeue" or native.systemFont;  
   
 local label =display.newText("Tap here to send a text", 0, 0, font, 18) ;  
 label:setReferncePoint(display.CenterReferencePoint) ;  
 label:setTextColor(0, 0, 0) ;   
 label.x = \_W \* 0.5;  
 label.y = \_H - 50;  
   
 function label:tap(e)  
 native.showPopup("sms",{  
 body = "I sent this text from my app",  
 to = {5550000000}  
 }) ;  
 end  
   
 label:addEventListner("tap", label);  
   
--  
-- See how the missing end now stands out?  
-- There is nothing to line up with the function way up there...  
--  
  
   
-----------------------------------------------------------------------------------------  
-- END OF YOUR IMPLEMENTATION  
-----------------------------------------------------------------------------------------  
   
-- "createScene" event is dispatched if scene's view does not exist  
scene:addEventListener( "createScene", scene )  
   
-- "enterScene" event is dispatched whenever scene transition has finished  
scene:addEventListener( "enterScene", scene )  
   
-- "exitScene" event is dispatched whenever before next scene's transition begins  
scene:addEventListener( "exitScene", scene )  
   
-- "destroyScene" event is dispatched before view is unloaded, which can be  
-- automatically unloaded in low memory situations, or explicitly via a call to  
-- storyboard.purgeScene() or storyboard.removeScene().  
scene:addEventListener( "destroyScene", scene )  
   
-----------------------------------------------------------------------------------------  
   
return scene  

BTW, I suspect you’re going to have another error in your SMS call. The:

to = {5550000000}

I think needs to be a string rather than the number 5, 550, 000, 000. In other words it needs to be:

to = {“5550000000”}

[import]uid: 19626 topic_id: 30033 reply_id: 120405[/import]

it looks like my copied code still had the mdash instead of a hyphen… Anyway, here is what’s throwing you off;


I am still getting the same one I originally posted:

/Users/babybeanie98/Desktop/Forgetful Memory/level1.lua:34: unexpected symbol near '?'
stack traceback:
[C]: ?
[C]: in function ‘error’
?: in function ‘gotoScene’
…Users/babybeanie98/Desktop/Forgetful Memory/menu.lua:22: in function ‘onRelease’
?: in function <?:191>
?: in function <?:226>

If I comment it the onRelease out. then the error goes away but then when I click on the button is does nothing.

The error above is called a “backtrace”, not only does it show you the place were the error exists, line 34 of level1.lua but it also tells you where that function was called from… in this case, line 22 of menu.lua is where you call gotoScene(). That call is inside of the function onRelease. This helps you track your errors down.

In your case you do not have an error in the onRelease function, your only error is that invalid symbol on line 34 of level1.lua. Change the minus sign to one typed directly from your keyboard and it will solve your problem.

Or copy the code posted above which also fixes it.

EDIT: I also fixed my copy of your code above after I fixed the minus.
[import]uid: 19626 topic_id: 30033 reply_id: 120486[/import]

OMG, you guys ROCK!!!. I would never would have figured this out without you. I don’t know many times I can say THANK YOU. THANK YOU,THANK YOU THANK YOU!!! [import]uid: 69302 topic_id: 30033 reply_id: 121250[/import]

@robmiracle- you are saying that backtrace tell me where my error is but you also keep saying its not on release. but after making all the changes this is this my error:

Runtime error
bad argument #3 to ‘_newRect’ (number expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘_newRect’
?: in function ‘newRect’
…ers/babybeanie98/Desktop/Forgetful Memory/level1.lua:24: in function <…ers memory>
?: in function ‘dispatchEvent’
?: in function ‘gotoScene’
…Users/babybeanie98/Desktop/Forgetful Memory/menu.lua:22: in function ‘onRelease’
?: in function <?:191>
?: in function <?:226>
the menu.lua: in function ‘onRelease’ looks as one of my problems on top of the others? [import]uid: 69302 topic_id: 30033 reply_id: 120640[/import] </…ers>

Well, now you have a new error. Read the error, it says exactly where the problem is…

Bad argument #3 to _newRect (number expected got nil) at level1.lua line #24 in a function defined on line 20 that is called from onRelease.

Looking at the code above line 23 is:

local background = display.newRect( 0, 0, screenW, screenH )

I’m guessing your code has changed a bit, so line 23 above is now line 24.
Line 20 is the function scene:createScene() call.
Line 22 of menu.lua is where you call storyboard.gotoScene(level1)

See how the backtrace works?

Now lets look at the error. display.newRect() expects 4 numeric values, but you are passing NIL to the 3rd (and I suspect 4th as well) parameter. 0 and 0 are numbers, so you’re good there. That leaves screenW as being nil. Where did you define that value? If you pass in a variable that you’ve never defined somewhere, it will be nil and cause that error.

Learning to read your console errors is an important skill to learn.
[import]uid: 19626 topic_id: 30033 reply_id: 120667[/import]

Yes I am now understanding the backtrace. I think my proble is that I am having a hard time understanding exactly what it wants me to do with the error. I have bought videos on understanding corona. My problem is understanding lua.

So with this here:Runtime error
bad argument #3 to ‘_newRect’ (number expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘_newRect’
?: in function ‘newRect’
…ers/babybeanie98/Desktop/Forgetful Memory/level1.lua:24: in function <…ers memory>
?: in function ‘dispatchEvent’
?: in function ‘gotoScene’
…Users/babybeanie98/Desktop/Forgetful Memory/menu.lua:22: in function ‘onRelease’
?: in function <?:191>
?: in function <?:226>

you are saying that my only error is the bad argument?
because I thought this was an error as well :<…ers memory>
?: in function ‘dispatchEvent’
?: in function ‘gotoScene’
…Users/babybeanie98/Desktop/Forgetful Memory/menu.lua:22: in function ‘onRelease’
?: in function <?:191>
?: in function <?:226>

I want to thank you and everyone for helping. if you know where I can get info on lua that would help me understand would be helpful as well. I only done programming in actionscript. [import]uid: 69302 topic_id: 30033 reply_id: 120674[/import] </…ers></…ers>

Let me step back for a second and explain how Corona detects errors.

In computer programming there are two ways to turn code into something the computer can run. One is to use a Compiler. Languages like C, Pascal, FORTRAN are compiled languages. That is, you write all your code and then run the compiler program and it goes through all the code and spits out every error in can find. You could have dozens or hundreds of errors printed out to the screen. You then go fix them, run the compiler again, fix the errors until it’s error free.

Corona SDK on the other hand, since it’s using Lua is what’s known as an interpreted language. Your code is converted to something machine runnable on the fly. So every time you tell Corona to relaunch your app in the simulator, it converts the code… Typically interpreted languages stop when they hit an error. since they can’t go on trying to run a buggy program.

In your case, you may have more errors than the one it’s stopping on. You won’t know until you fix that error and try again. I suspect you will have another error on that one line. Since screenW is nil, I expect that screenH will also be nil.

Looking just at leve1.lua, if you did not define screenW and screenH, did you also define _W and _H? Your phone number in your SMS sender needs to be a string not a number and as someone else pointed out above, your font will always be HelveticaNueve.

Just to make sure, do you know what screenW, screenH, _W and _H are? Rhetorical question since I’m going to answer it anyway.

Corona provides two API calls to get the width and height of the screen:

display.contentWidth
display.contentHeight

That’s a lot of typing when you have to use it over and over again. So several programmers at the beginning of their program will create short cuts to those API calls:

_W = display.contentWidth
_H = display.contentHeight

The underscore is to make sure it doesn’t conflict with any variable W or H you might use. Once you’ve done that you can use _W and _H has much shorter references to the width and height of the display.

Other people prefer to use screenW and screenH to do the same thing.

screenW = display.contentWidth
screenH = display.contentHeight

Most people will not mix the two, or in my case, I don’t use the short cut for reasons I’m about to explain.

Since you are using storyboard, you use multiple lua files for your program, main.lua, leve1.lua, menu.lua etc. If you define these short references in main.lua, you either have to re-define them in each of your lua files, or have them as global variables, which must programmers agree should be avoided when possible. I just use the long reference and don’t worry about the short cuts.

If you choose to use the short cuts, create them in main.lua, leave off the word “local” in front of them (so they become global variables) and standardize on one way or the other. [import]uid: 19626 topic_id: 30033 reply_id: 120678[/import]

Your knowledge in lua/programming is amazing. How did you learn so much about it? Is there anything that I can purchase to obtain some of this knowledge? I wish you could hold a tutor session. lol
I will take your advice and go back and do it the way most programmers do it. Now that you have explained it, I think that is my problem because I believed I used it both ways. [import]uid: 69302 topic_id: 30033 reply_id: 120681[/import]

So Im taking your knoweldge and now understanding the backtrace. I have gotten rid of the first error bad argument and now ran across ‘)’ expected near ‘0’ what would that be implying? I added the ‘)’ thinking that is what they were asaking for. [import]uid: 69302 topic_id: 30033 reply_id: 120688[/import]

Can you post the exact copy of the error?

As for my knowledge, I’ve been programming for over 30 years and a little over a year and a half with Lua. It doesn’t happen over night. Being patient, and continuing to learn are important skills. [import]uid: 19626 topic_id: 30033 reply_id: 120702[/import]

Thats understandable. I am always willing to learn.

it says: level1. lua:31 ‘)’ expected near ‘0’
stack traceback:
[C]: ?
[C]: in function ‘error’
?: in function ‘gotoScene’
…Users/babybeanie98/Desktop/Forgetful Memory/menu.lua:22 in function
‘onRelease’
?: in function <?:191>
?: in function <?: 226>

another question is it asking me to do anything in regards to the ?: in function <?:191>
and ?: in function <?: 226> begins though it is not mentioning a traceback?

[import]uid: 69302 topic_id: 30033 reply_id: 120705[/import]

When you see the ?:In function <?:nnn> type messages, that means the back trace is executing some Corona code that’s doing some work for you. Since the onRelease is coming from a widget.button, I’m assuming the :191 is some point in the button code. What happens is that the library routines like that are compiled code and don’t have any debugging symbols for Corona to use. You just have to assume that’s part of Corona and not going on in your code.

As for the error, what is your current line 31? Actually I’d like to see the code before and after that as well… Can you post the current copy of level1.lua? [import]uid: 19626 topic_id: 30033 reply_id: 120721[/import]

[code]-----------------------------------------------------------------------------------------

–level1.lua

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()


– BEGINNING OF YOUR IMPLEMENTATION

– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.


– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view

– create a grey rectangle as the backdrop
local background = display.newRect( 0, 0, 0, 0, screenW, screenH )
background:setFillColor( 255 )

local font = native.systemFont;

local label =display.newText(“Tap here to send a text”, 0, 0, font, 18) ;
label:setReferncePoint(“display.CenterReferencePoint” 0, 0, 0,) ;
label:setTextColor(0, 0, 0) ;
label.x = _W * 0.5;
label.y = _H - 50;

function label:tap(e)
native.showPopup(“sms”,{
body = “I sent this text from my app”,
to = {“5550000000”} – or “5550000000” if this doesn’t work
}) ;
end

label:addEventListner(“tap”, label);
end
[/code]

– END OF YOUR IMPLEMENTATION

– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched whenever before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )


return scene
so the error is now on line 28. its the same error though. [import]uid: 69302 topic_id: 30033 reply_id: 120762[/import]

Okay lets read the error and look at the line its on:

level1. lua:31 ‘)’ expected near ‘0’

label:setReferncePoint("display.CenterReferencePoint" 0, 0, 0,) ;  

The function setReferencePoint is expecting a ) and found a 0.

Looking at the documentation for object:setReferencePoint()

http://docs.coronalabs.com/api/type/DisplayObject/setReferencePoint.html

Syntax

object:setReferencePoint( referencePoint )

Notice it is only expecting one parameter and you passed it several. You also have 3 additional things wrong with that line. First if we look at an example in the docs:

textObj:setReferencePoint(display.CenterLeftReferencePoint);  

You can see that it’s not expecting a string, but a display attribute (it’s not in quotes).

Secondly, you can’t have a string “something in quotes” and a number without something separating it… You have “display.CenterRefefencePoint” 0 as a single parameter passing in. This is likely what is causing the specific error message you are getting. Seeing that 0 after the string isn’t expected, it’s expecting a ) instead.

Passing the remaining parameters won’t cause an error, but they also don’t do anything. The trailing comma before the closing ) will likely also trigger an error since there is something expected between the comma and the closing paren.

[import]uid: 19626 topic_id: 30033 reply_id: 120767[/import]