Android Question Concatenate strings from sql

grant1842

Active Member
Licensed User
Longtime User
I am trying to add some items to a listview.
THis compiles fine.
B4X:
ListView1.AddTwoLines(Cursor1.GetString("call"),Cursor1.GetString("name"))

When I try to add another string from sql i get error.

B4X:
Parsing code.                           0.02
Compiling code.                         Error
Error compiling program.
Error description: Missing parameter.
Occurred on line: 67
ListView1.AddTwoLines(Cursor1.GetString("call")&" " &Cursor1.GetString("call")&", " & Cursor1.GetString("name"))
Word: )

B4X:
ListView1.AddTwoLines(Cursor1.GetString("call")&" " &Cursor1.GetString("call")&", " & Cursor1.GetString("name"))

Thanks for your help.
 

NJDude

Expert
Licensed User
Longtime User
That's because you are missing the SECOND line.

Change this line from:
B4X:
ListView1.AddTwoLines(Cursor1.GetString("call")&" " &Cursor1.GetString("call")&", " & Cursor1.GetString("name"))
to:
B4X:
ListView1.AddTwoLines(Cursor1.GetString("call") & " "  & Cursor1.GetString("call"), Cursor1.GetString("name"))
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The variables do not cost much. Often compact code is more harmful than useful.

B4X:
ListView1.AddTwoLines(Cursor1.GetString("call") & " "  & Cursor1.GetString("call"), Cursor1.GetString("name"))

B4X:
Call = Cursor1.GetString("call")
Name = Cursor1.GetString("name")
ListView1.AddTwoLines(Call & " " & Call, Name)

In this case, you can also move the mouse pointer on Name (setting a breakpoint on ListView...) to check its value, can you do it using the "compact format"?

I hate compact code: we are not developing in Assembler!

(Call & Call ?!?!)

(wow, this post is very inherent to the question :p)
 
Upvote 0
Top