should've used a data grid, I guess

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
mister
Posts: 39
Joined: Thu Nov 27, 2014 9:03 pm

should've used a data grid, I guess

Post by mister » Fri Oct 09, 2015 1:31 am

i have a basic scrolling field with 5 columns. I know you can't lock the text of a column, but i would like to preserve(save) the first column and /or delete the the contents of the following columns. i've tried to save item 1 of the first column line by line into a separate file, delete the other columns, put item 1 into a global variable etc, etc. Is it possible or am I spinning my wheels?

Thanks in advance, since I forgot to say it last time I asked a question!

Larry

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: should've used a data grid, I guess

Post by dunbarx » Fri Oct 09, 2015 4:11 am

Hi.

Simple to do, and there are several ways to go about it. The question I have for you, since you mentioned dataGrids as if they had some sort of magical powers (they do, actually, to an extent), is how averse you are, as a matter of course, to just a little massaging of your data.

So, one way. Make a table field with some data in it over several lines. Make a button with this in its script:

Code: Select all

on mouseUp
   get fld 1
   set the itemDel to tab
   repeat with y = 1 to the number of lines of it
      put item 1 of line y of it into line y of it
   end repeat
   put it into fld 1
end mouseUp
I used the "repeat with..." form because I think it is more readable. This sort of fooling around can be modified as required, and embellished to make it far more robust and universal in the way it might extract or discard portions of the text of the field. So back to the question. Is this a cute gadget that you will embrace as a general methodology, that is, use LC to manage LC, or is it a chore and a bore, that you think you should not have to deal with? :?:

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: should've used a data grid, I guess

Post by jacque » Fri Oct 09, 2015 7:02 pm

If the goal is to break out only column 1, here is a quick way to do it. It assumes your field is tab-delimited with a carriage return after each line.

Code: Select all

put fld 1 into tData
split tData by column
put tData[1] into fld 1
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mister
Posts: 39
Joined: Thu Nov 27, 2014 9:03 pm

Re: should've used a data grid, I guess

Post by mister » Sat Oct 10, 2015 6:03 pm

dunbarx & jacque

Thank you both for the answers. Craig, in response to your question, it's the exact opposite. i'm all about the code. I read one of the moderators post about doing the "coding"" outside of the data grid and that's exactly the way i'm trying to learn. I just had a weak moment. It seems that when you search for answers in the forum about anything basic, most results come back as either data grid or sql, thus the title of the post.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: should've used a data grid, I guess

Post by dunbarx » Sun Oct 11, 2015 4:34 am

Hi,

I am likely that coder; does the phrase "in the clear" ring a bell? If so, it is me.

New users oftentimes go right to the dataGrid, thinking that is the go-to object. Usually this move is not only premature, but inappropriate, in that other, simpler solutions are better suited to the task.

Anyway, I almost always bring a DG's data "in the clear", work it, and after all that, only reload the DG if appropriate. LC has far greater power and flexibility than a DG can ever have, its marvelous compactness notwithstanding.

So you have this right. Use the tools LC gives you, and the simplest ones first; that is, stay in the clear if you can (table field vs. DG). And lastly, did either my or Jacque's method give you a hand?

Craig

Post Reply