Combing first name and surname into a datagrid table

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Combing first name and surname into a datagrid table

Post by montymay » Tue Jun 13, 2017 12:45 pm

I have a sqlite database in which surnames and first names are in different columns. I want to populate a datagrid table such that the first name and surname are put into one datagrid column in that order, separated by a space. Is that possible? Can anyone suggest the script or a tip on how to do it?

Code: Select all

     repeat for each line i in tData
put item 1 of i into tArray[tCounter]["rsnum"]
put  item 2 of i into tArray[tCounter]["surname"] -- I want to concatenate this line
put item 3 of i into tArray[tCounter]["firstName"] -- and this line will display "firstName SurName" in the DG
put item 4 of i into tArray[tCounter]["debtAmt"]
put item 5 of i into tArray[tCounter]["dateOpened"]
put item 6 of i into tArray[tCounter]["debtType"]
put item 7 of i into tArray[tCounter]["order"]
put item 8 of i into tArray[tCounter]["NextHrg"]
add 1 to tCounter
     end repeat
     set the dgData of grp "dgDefendants" to tArray
Thank you for the answer or any suggestions.

Monty May

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Combing first name and surname into a datagrid table

Post by Klaus » Tue Jun 13, 2017 1:35 pm

Hi Monty,

does you datagrid already have a column for this?
Maybe a column named "fist_last_name"?

Whatever this might give you an idea:

Code: Select all

...
   repeat for each line i in tData
      put item 1 of i into tArray[tCounter]["rsnum"]
      ## put  item 2 of i into tArray[tCounter]["surname"] -- I want to concatenate this line
      ## put item 3 of i into tArray[tCounter]["firstName"] -- and this line will display "firstName SurName" in the DG
      put item 2 of i && item 3 of i into into tArray[tCounter]["fist_last_name"] 
      put item 4 of i into tArray[tCounter]["debtAmt"]
      put item 5 of i into tArray[tCounter]["dateOpened"]
      put item 6 of i into tArray[tCounter]["debtType"]
      put item 7 of i into tArray[tCounter]["order"]
      put item 8 of i into tArray[tCounter]["NextHrg"]
      add 1 to tCounter
   end repeat
   set the dgData of grp "dgDefendants" to tArray
...
Best

Klaus

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Combing first name and surname into a datagrid table

Post by montymay » Wed Jun 14, 2017 11:15 am

Thanks, Klaus, your amended line works perfectly.

Monty

Post Reply