Problem copying from DG1 to DG5

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
CAsba
Posts: 364
Joined: Fri Sep 30, 2022 12:11 pm

Problem copying from DG1 to DG5

Post by CAsba » Thu Feb 15, 2024 12:53 pm

Hi all,
I'm using the following code but without success. Any ideas why ?

Code: Select all

put the dgNumberOfLines of grp "datagrid 1" into tLines
   set the dgHilitedLines of grp "datagrid 1" to tLines
   put the dgHilitedLines of group "datagrid 1" into theLine#hilite the last line
   put the dgDataOfLine[theLine] of group "datagrid 1" into theDataA 
   put theDataA into fld "arraydata2"#to ensure data has been actioned(copied)  - NOT copied
   put false into firstLineContainsColumnNames
   dispatch "addline" to grp "datagrid 5" with theDataA

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Problem copying from DG1 to DG5

Post by Klaus » Thu Feb 15, 2024 1:35 pm

Hi CAsba,

Code: Select all

...
put the dgNumberOfLines of grp "datagrid 1" into tLines
set the dgHilitedLines of grp "datagrid 1" to tLines
put the dgHilitedLines of group "datagrid 1" into theLine
...
after this -> tLines = tLine
So you could save one variable, but does not hurt of course!

Code: Select all

...
put the dgDataOfLine[theLine] of group "datagrid 1" into theDataA 
put theDataA into fld "arraydata2"
...
theDataA is also an ARRAY, so you cannot put this into a field!

Code: Select all

dispatch "addline" to grp "datagrid 5" with theDataA
ADDLINE does NOT exspect an array as parameter, see the dictonary!
Try this instead:

Code: Select all

...
## This is the default, so no need to set it:
## put false into firstLineContainsColumnNames
## dispatch "addline" to grp "datagrid 5" with theDataA

## Will add the data at the end of the other DG:
dispatch "addData" to grp "datagrid 5" with theDataA
...
Best

Klaus

P.S.
If something does not work as exspected, it is not a bad idea to look up the used command(s) in the dictionary! 8)

CAsba
Posts: 364
Joined: Fri Sep 30, 2022 12:11 pm

Re: Problem copying from DG1 to DG5

Post by CAsba » Thu Feb 15, 2024 4:12 pm

Hi Klaus,
Thank you so much !
I took a look at the dictionary, but without knowing that there is a 'AddData' command, I don't know how I could have found it.
Anyway, I'm back on track, thanks to your much appreciated assistance.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Problem copying from DG1 to DG5

Post by Klaus » Thu Feb 15, 2024 4:23 pm

Yes, get it, I meant to look at a command like "addline" here to check why it does not work as exspected.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”