Combining some lines of text in a list?
Michael Kann
mikekann at yahoo.com
Mon Jan 30 22:01:33 EST 2012
put input_file into x
replace return & "creature3" with space in x
replace return & "creature2" with space in x
put x into output_file
--- On Mon, 1/30/12, John Patten <johnpatten at mac.com> wrote:
From: John Patten <johnpatten at mac.com>
Subject: Combining some lines of text in a list?
To: use-livecode at lists.runrev.com
Date: Monday, January 30, 2012, 6:45 PM
Hi All...
I have a list of items. The items in the list are in similar groups but each group is delimited by a tab.
For example:
name:Group1
description:Animals with four legs.
creature1:cats
creature2:dogs
notes1:Animals that are pets.
notes2:Animals that have fur.
name:Group 2
description:Animals that swim.
creature1:sharks
creature2:tuna
creature3:whales
notes1:Animals that live in the sea.
notes2:Animals that don't have fur.
etc. etc....
The items in the list are formatted identical. It is just the content after the colon that changes.
How would I go about combining the "creature" line (line 3) with the other creature lines for each item in list?
Ultimately I would like my items in my list to look like:
name:Group1
description:Animals with four legs.
creature1:cats dogs
notes1:Animals that are pets.
notes2:Animals that have fur.
name:Group 2
description:Animals that swim.
creature1:sharks tuna whales
notes1:Animals that live in the sea.
notes2:Animals that don't have fur.
I have been experimenting with:
on mouseUp
set the itemdel to tab
put 2 into x
put 1 into y
repeat for number of items in cd fld "data" - 1
put item x of cd fld "data" into tTempData
put lineOffSet("creature1:", tTempData) into tTextStart --4
put lineOffSet("notes1:", tTempData) into tTextEnd
repeat for number of lines in tTempData
put char 1 to 10 of line (tTextStart + y) of tTempData into tFirst
put char 1 to 7 of line tTextEnd of tTempdata into tEnd
if tFirst <> tEnd then
put line (tTextStart + y) of tTempData after tAdditionalText
put empty into line (tTextStart + y) of tTempData
add 1 to y
put tTempData & tab & return after tFormattedData
else
put item x of tTempData & tab & return after tFormattedData
--put item x of tTempData after tFormattedData
add 1 to x
add 1 to y
end if
end repeat
add 1 to x
end repeat
put tFormattedData
end mouseUp
But I'm thinking there must be an easier way? Any suggestions?
Thank you!
John Patten
SUSD
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list