Textbox - Im doing something wrong

I dont know what Im doing wrong. I retrieving some data from a SQL database in Android and Im triyng to put in a text box. But emulator give me a RUNTIME ERROR:

Runtime error C:\Users\drago\Desktop\Forca - Android\main.lua:62: attempt to concatena te local 'textfield' (a nil value) stack traceback: [C]: ? C:\Users\drago\Desktop\Forca - Android\main.lua:62: in function 'onRelea se'

What Im doing wrong? I KNOW is something related to types, but I dont know what. This is the code:
[lua] local textbox = native.newTextBox( 0, 300, 200, 50 )
textbox.hasBackground = false
textbox:setTextColor(255,0,255)

for row in db:nrows(“SELECT * FROM hangman”) do
textfield = textfield … row.palavras
end

textbox.text = textfield[/lua]

textfield is a local variable. [import]uid: 9133 topic_id: 6363 reply_id: 306363[/import]

It says in the error that textfield is nil.

You can use print() to check the terminal to see if you are getting any data. You can test out the textbox by hardcoding a value to textfield and if that works then that tells you that your SQL statement is not deriving the data properly.

[import]uid: 8045 topic_id: 6363 reply_id: 22031[/import]

Hi Luna,

Thanks for your help.

Its strange, because if I put this line in code, as:

[lua]for row in db:nrows(“SELECT * FROM hangman”) do
local text = row.palavras
local t = display.newText(text, 20, 70 + (20 * row.id), native.systemFont, 16)
t:setTextColor(255,0,255)
end[/lua]

This works ok.

I tried a new code:

[lua]-- Carrega biblioteca para botoes - User Interface
local ui = require(“ui”)

local tb = native.newTextBox( 0, 0, 400, 400 )
tb.text = “Isso e um teste\nE isso deveria estar em duas linhas. Tambem deve ser possivel ver o scroll”
tb.setTextColor( 0, 0, 255 )
tb.hasBackground = true
tb.size = 16[/lua]

Just that. This should work. But What I see? My text and after few seconds, it simply desapear.

Do you know why ?

Thanks [import]uid: 9133 topic_id: 6363 reply_id: 22035[/import]

Here’s a long shot but try this:

tb:setTextColor( 0, 0, 255 )

Use a colon instead of the dot syntax.

For the SQL statement, is there a possibility that you are encountering a NULL value somewhere in your recordset?

Hard to really solve without actual files.
[import]uid: 8045 topic_id: 6363 reply_id: 22067[/import]

IN this case, you are right. I used colon and everything works fine now. Well…almost :smiley:

Now I have to understand this: I wrote a simple example like this one:

[lua]local tb = native.newTextBox( 15, 70, 280, 70 )
tb.text = “This is line 1.\nAnd this is line2\nLinha 3\nLinha 4\n”
tb:setTextColor( 0, 0, 255 )
tb.hasBackground = true
tb.size = 16[/lua]

Works fine right now. But the box should be scrollable, isnt ? Here, nothing happen. Text aperar, but the last line, cut in the middle, and I don have scroll. Do you know why?

Thanks for your help.
[import]uid: 9133 topic_id: 6363 reply_id: 22109[/import]

You can use this to scroll your content:
http://developer.anscamobile.com/code/scroll-content [import]uid: 8045 topic_id: 6363 reply_id: 22155[/import]

But for me is REALLY strange I have to use a very large code, when textbox, according to the description, should work like this one.

REALLY Thanks for your help Luna. [import]uid: 9133 topic_id: 6363 reply_id: 22172[/import]