DataGrid, SQLite and texts with return

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
Immanuel
Posts: 6
Joined: Mon Aug 10, 2020 4:52 pm

DataGrid, SQLite and texts with return

Post by Immanuel » Mon Aug 10, 2020 5:01 pm

Hello community

I have the following problem:

I'm filling a DataGrid from an SQLite database, so far so good.

Now the problem. I have a field that serves as an InfoText field and of course a text with "return" is stored there. When saving to the SQLite database there is no problem but when I try to fill the DataGrid again there are problems because every return is interpreted as a new line.

How can I get a multiline text that contains several return lines to be interacted with in the DataGrid?

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

Re: DataGrid, SQLite and texts with return

Post by dunbarx » Mon Aug 10, 2020 5:21 pm

Hi.

Prepare a dataSet that is tab and return delimited, either as an array or as clear data. The DG will accept that directly, by setting the DGText or the DGData.

Craig

Immanuel
Posts: 6
Joined: Mon Aug 10, 2020 4:52 pm

Re: DataGrid, SQLite and texts with return

Post by Immanuel » Mon Aug 10, 2020 5:36 pm

and how do I do that? without whom a return in a field is it does not make me a new line?

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

Re: DataGrid, SQLite and texts with return

Post by dunbarx » Mon Aug 10, 2020 7:50 pm

Hi.

Now I am not sure what you mean. A datGrid is a large complicated beast, but the data it holds is available in part with native calls to its API, or in its entirety with the properties "DGData" or the "DGText". Getting and setting these last is how I usually deal with DG's.

If I wanted to insert three lines, inserted after, say, the current line 6 of the DG, one might:

Code: Select all

get the DGText of group "yourDatagrid"
put return & yourThreeLines after line 6 of it
set the DGText of group "yourDataGrid to it
Untested, but should work. What do you need that is different? Remember that those three lines must contain tab and return delimited data.

Craig

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

Re: DataGrid, SQLite and texts with return

Post by dunbarx » Tue Aug 11, 2020 3:00 am

there are problems because every return is interpreted as a new line.

How can I get a multiline text that contains several return lines to be interacted with in the DataGrid?
Is it that you want three "ordinary" lines, delimited by returns as is usual, to load into a single line in the DG? If so, just strip out the returns:

Code: Select all

replace return with "" in yourData
or

Code: Select all

replace return with space in yourData
But this may not format correctly. Does the data include tabs, which are used by the DG to delimit columns?

Craig

stam
Posts: 2776
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: DataGrid, SQLite and texts with return

Post by stam » Tue Aug 11, 2020 9:42 am

I can see the issue you're describing - using dgText and dgData will be an issue if your text contains carriage returns and create extra lines as you describe.

Of course one way to do this is to get rid of returns, but his may not suit your purposes.

I don't know how others have solved this, but one possible way to go about it would be to store the data in a custom property as an array, then populate the column using the fillInData pData event in the behaviour script (you'd need to create a column behaviour or row template beforehand if you're using a grid or form respectively). That way you'd fill the column with the actual data you retrieve from your database (with carriage returns and all).

Possibly there is a slicker way of doing this, but i'm fairly sure the above would work too...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: DataGrid, SQLite and texts with return

Post by FourthWorld » Tue Aug 11, 2020 2:35 pm

Details on the problem, with a solution handler:
http://www.fourthworld.com/embassy/arti ... t-die.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Immanuel
Posts: 6
Joined: Mon Aug 10, 2020 4:52 pm

Re: DataGrid, SQLite and texts with return

Post by Immanuel » Tue Aug 11, 2020 3:31 pm

Hello, everybody,

I have solved my problem completely.

i have created a second table in the database in which the info text with all characters a user can think of is stored and then i call it up separately in relation to the ID of the first table and put it in an extra field.

thank you for your effort i am sure i will ask for your help more often in the near future.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”