Data Grid insert, is not being captured in tData

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
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Data Grid insert, is not being captured in tData

Post by liveme » Tue Jan 12, 2021 8:34 am

Hi people,
Following the tutos, the single line filling a Datagrid sample with Tabs, works fine here...
but when I'm trying to use this code (Array method)
it seems that no data is captured to "tData" :

*answer tData line returns only the word : "done".
the Grid remains empty too...
-Any idea why ? :idea:

I'm out of ideas...Thanks

Code: Select all

on mouseDown
   local sData
 
   put "1" into sData[1]["refid"]
   put "polux" after sData[1]["namox"]
   put "5675" after sData[1]["Val"]
   answer sData &" done"
   
   lock screen
   set the dgData of group "TableArticles" to sData
   
   ## Hilite first row
   set the dgHilitedLines of group "TableArticles" to 1
end mouseDown
I tested with 3 "into" instead of "after"..same empty results... :(

LCindy 9.6.1 / Manjaro.

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

Re: Data Grid insert, is not being captured in tData

Post by Klaus » Tue Jan 12, 2021 1:12 pm

Hi Liveme,

this is really not a LINUX problem, but a problem with the LC syntax!
Will move this to the beginners section.

To be sure, so you have a new datagrid of type TABLE with 3 columns named:
refid
namax
Val

Correct?

1. An array cannot be displayed/ANSWERed directly or being put into a field, so your answer will only show the & " done" part.
Maybe it even throws an error.

2. You nedd to create a valid mulitdimensional array like this (NO quotes neccessary for numbers):

Code: Select all

...
put 1 into sData[1]["refid"]
put "polux" INTO sData[1]["namox"]
put 5675 INTO sData[1]["Val"]
## answer sData &" done"
set the dgData of group "TableArticles" to sData
...
Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data Grid insert, is not being captured in tData

Post by dunbarx » Tue Jan 12, 2021 2:55 pm

What Klaus said.

Arrays do not respond to the "usual" keywords that chunks do. So you cannot use "before" or "after". They do respond to "into", as Klaus showed.

You cannot display or use an array variable directly "in the clear", that is, in a field, say. without changing that array into an "ordinary" variable:

Code: Select all

on mouseUp
   put 1 into sData[1]
   put 2 into sData[2]
   put 3 into sData[3]
   
   combine sData with return and comma
   put sData into fld 1
end mouseUp
But this will not translate to being able to "see" the contents of a multi-dimensional array:

Code: Select all

on mouseUp
   put 1 into sData[1][1]
   put 2 into sData[1][2]
   put 3 into sData[1][3]
   
   combine sData with return and comma
   put sData into fld 1
end mouseUp
LC will not know how to display the contents of what is essentially an array of elements in an array.

Just takes practice.

Craig

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: Data Grid insert, is not being captured in tData

Post by liveme » Tue Jan 12, 2021 10:43 pm

Thanks guys...
After rechecking the names, i changed the Col1,2,3 values to the same field value names, and that seems to have been my problem. (I thought one HAD to leave Col1 on top and use the below cell to input a name.)
Si i ve just repeated the same values in both lines,. Its solves it !
Thanks for the Array info, i'll try to make use of that.
My goal next is to get or save data between a grid and an sqlite db. .. :wink:

Thanks again for your help.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”