Android Question Concatenate strings from sql

Discussion in 'Android Questions' started by grant1842, Apr 29, 2015.

  1. grant1842

    grant1842 Active Member Licensed User

    I am trying to add some items to a listview.
    THis compiles fine.
    Code:
    ListView1.AddTwoLines(Cursor1.GetString("call"),Cursor1.GetString("name"))
    When I try to add another string from sql i get error.

    Code:
    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: )
    Code:
    ListView1.AddTwoLines(Cursor1.GetString("call")&" " &Cursor1.GetString("call")&", " & Cursor1.GetString("name"))
    Thanks for your help.
     
  2. NJDude

    NJDude Expert Licensed User

    That's because you are missing the SECOND line.

    Change this line from:
    Code:
    ListView1.AddTwoLines(Cursor1.GetString("call")&" " &Cursor1.GetString("call")&", " & Cursor1.GetString("name"))
    to:
    Code:
    ListView1.AddTwoLines(Cursor1.GetString("call") & " "  & Cursor1.GetString("call"), Cursor1.GetString("name"))
     
    thedesolatesoul and DonManfred like this.
  3. LucaMs

    LucaMs Expert Licensed User

    The variables do not cost much. Often compact code is more harmful than useful.

    Code:
    ListView1.AddTwoLines(Cursor1.GetString("call") & " "  & Cursor1.GetString("call"), Cursor1.GetString("name"))
    Code:
    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)
     
  4. DonManfred

    DonManfred Expert Licensed User

    No problem if you can read what you wrote later

    But you are right. Splitting some things into multiple lines can help much while debugging
     
  5. grant1842

    grant1842 Active Member Licensed User

    Solved

    Thanks for all comments .
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice