Creating a "format" for data
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Creating a "format" for data
Hi everyone,
I'm sure I'm missing something (or going about this all wrong) but wanted to see if anyone has any advice for me!
I'm trying to take information from a data grid and move it to a text field but set it to where it will put it in with a certain look to it. So taking the information in column 1 and put the information in column 2 between the items of column 1 and then put a "dividing" line...
If that was completely confusing I'll give an example.
Three people give say there favorite color John like red Sarah likes green and frank likes blue. So it would look like this:
Red
John
------
Green
Sarah
------
Blue
Frank
------
So I've been doing some reading and have yet to figure out how to do this so that the information will format itself to do this regardless of the number of lines in the datagrid.
It's very possible that I'm just not searching it out properly, but I'm at a loss as to how to do this...
thank you in advance for any assistance, or resources, you may be able to provide!
-sean
I'm sure I'm missing something (or going about this all wrong) but wanted to see if anyone has any advice for me!
I'm trying to take information from a data grid and move it to a text field but set it to where it will put it in with a certain look to it. So taking the information in column 1 and put the information in column 2 between the items of column 1 and then put a "dividing" line...
If that was completely confusing I'll give an example.
Three people give say there favorite color John like red Sarah likes green and frank likes blue. So it would look like this:
Red
John
------
Green
Sarah
------
Blue
Frank
------
So I've been doing some reading and have yet to figure out how to do this so that the information will format itself to do this regardless of the number of lines in the datagrid.
It's very possible that I'm just not searching it out properly, but I'm at a loss as to how to do this...
thank you in advance for any assistance, or resources, you may be able to provide!
-sean
Re: Creating a "format" for data
Hi.
Whatever it is you want to do will be both simple and a great learning experience.
But...
What was that sentence about the "Three people..."?
I thought the source text was in a dataGrid. It would not be hard to parse out those color/person paris even from that sentence, but please clarify. If really from a dataGrid, we can bring the source text into the clear by using the "dgText". Then since the result of that will be a tab and return delimited dataSet, we can simply assemble the associated pairs, inserting returns and those dividers.
Craig Newman
Whatever it is you want to do will be both simple and a great learning experience.
But...
What was that sentence about the "Three people..."?
I thought the source text was in a dataGrid. It would not be hard to parse out those color/person paris even from that sentence, but please clarify. If really from a dataGrid, we can bring the source text into the clear by using the "dgText". Then since the result of that will be a tab and return delimited dataSet, we can simply assemble the associated pairs, inserting returns and those dividers.
Craig Newman
Last edited by dunbarx on Mon Sep 28, 2015 4:06 pm, edited 2 times in total.
Re: Creating a "format" for data
Hi Craig,
Thank you for the follow up... i just read my first post, and realized how confusing it really was.. my apologies.
I have a datagrid with two columns. what i'm trying to do is pull the information from the datagrid and place it into a text field. the closest thing i can compare it to would be a like a comment section on a website... so that you'd see the "note" and who posted it. where one column is the "note" and the second column is the user. so what it's end result would look like this: But in actuality it's pulling from the datagrid, and would be formatted like this: I'm not sure how to set it such that it does this for all the lines in a datagrid... i'm sure that there's something i'm missing, but have yet to find it...
I think what i'm looking for is a repeat, but i'm pretty new to using them... but i'm thinking (hoping) i'm on the right track with this one.
So I could be going about this all wrong, but I hope my example this time around didn't cause further confusion.
Thanks in advance for any insights or resources that may point me in the right direction to accomplish this.
-Sean
Thank you for the follow up... i just read my first post, and realized how confusing it really was.. my apologies.
I have a datagrid with two columns. what i'm trying to do is pull the information from the datagrid and place it into a text field. the closest thing i can compare it to would be a like a comment section on a website... so that you'd see the "note" and who posted it. where one column is the "note" and the second column is the user. so what it's end result would look like this: But in actuality it's pulling from the datagrid, and would be formatted like this: I'm not sure how to set it such that it does this for all the lines in a datagrid... i'm sure that there's something i'm missing, but have yet to find it...
I think what i'm looking for is a repeat, but i'm pretty new to using them... but i'm thinking (hoping) i'm on the right track with this one.
Code: Select all
/*I know this 'code' is incorrect, but i'm not quite sure how to write it*/
set the dgText of group "theDataGrid" to theData
repeat with x = 1 to the number of lines in theData
put /*Column 1 Line x*/ & cr & /*Column 2 Line x*/ & cr & "____" into theTest
put line x of theTest into line x of field "read"
end repeat
Thanks in advance for any insights or resources that may point me in the right direction to accomplish this.
-Sean
Re: Creating a "format" for data
Hi Sean,
your missing "link" is the fact that "the dgtext of grp XYZ" is in fact a TAB and CR delimited text list!
So you can of course do this:
...
Best
Klaus
your missing "link" is the fact that "the dgtext of grp XYZ" is in fact a TAB and CR delimited text list!
So you can of course do this:
...
Code: Select all
## set the dgText of group "theDataGrid" to theData
## theData is EMPTY at this point!
## You want to:
PUT the dgText of group "theDataGrid" INTO theData
## NEVER access fields in a repat loop, unless really neccessary!
## ALWAYS collect the data first in a variable, will be manyfold faster!
put empty into theTest
set itemdel to TAB
repeat with for each line tLine in theData
put item 1 of tLine & CR & item 2 of tLine & CR & "____" & CR AFTER theTest
end repeat
## Data collected, now fill field AT ONCE!
put theTest into fld "read"
...
Klaus
Re: Creating a "format" for data
Hi Klaus!
Thank you so much! I look forward to giving this a shot later today, and let you know how it goes!
I really appreciate you guys help on this!
-Sean
Thank you so much! I look forward to giving this a shot later today, and let you know how it goes!
I really appreciate you guys help on this!
-Sean
Re: Creating a "format" for data
Hi Klaus,
I seem to be missing something, but not sure.. i've tried the code that you've provided, and it seems to run into an error.
here's what i've tried so far:
I get the following error:
I've tried this:
and get this:
and lastly I tried this:
It shows no errors until i click the button and then i get this:
I wondered if i'm on the right track or just took a huge turn in the wrong direction. I've been trying to think, and look up, other ways to write this, but to no avail...
Thanks for any help you can provide!
-Sean
I seem to be missing something, but not sure.. i've tried the code that you've provided, and it seems to run into an error.
here's what i've tried so far:
Code: Select all
on mouseUp
PUT the dgText of group "DataGrid 3" INTO theData
put empty into theTest
set itemdel to TAB
repeat with for each line tLine in theData
put item 1 of tLine & CR & item 2 of tLine & CR & "____" & CR AFTER theTest
end repeat
put theTest into fld "read"
end mouseUp
Code: Select all
on mouseUp
PUT the dgText of group "DataGrid 3" INTO theData
put empty into theTest
set itemdel to TAB
repeat with x = 1 for each line tLine in theData
put item 1 of tLine & CR & item 2 of tLine & CR & "____" & CR AFTER theTest
end repeat
put theTest into fld "read"
end mouseUp
Code: Select all
on mouseUp
PUT the dgText of group "DataGrid 3" INTO theData
put empty into theTest
set itemdel to TAB
repeat with x = 1 to the number of lines tLine in theData
put item 1 of tLine & CR & item 2 of tLine & CR & "____" & CR AFTER theTest
end repeat
put theTest into fld "read"
end mouseUp
Thanks for any help you can provide!
-Sean
Re: Creating a "format" for data
Hi.
Klaus has to type very quickly in order to produce the astonishing number of help replies he submits each day.
Lose the word "with" in:
Craig
Klaus has to type very quickly in order to produce the astonishing number of help replies he submits each day.
Lose the word "with" in:
to make:repeat with for each line tLine in theData
Code: Select all
repeat for each line tLine in theData
Re: Creating a "format" for data
Yep, the "with" was a leftover from a copy/paste action, sorry for that!
Re: Creating a "format" for data
Hi Craig,
I completely understand, and appreciate, all the help you guys provide.
Made the changes you've suggested, and its working like a charm!
Thanks again!
-Sean
I completely understand, and appreciate, all the help you guys provide.
Made the changes you've suggested, and its working like a charm!
Thanks again!
-Sean