Combining some lines of text in a list?

Mike Bonner bonnmike at gmail.com
Mon Jan 30 22:23:05 EST 2012


I really like this method.  Now that you kick started my noggin I realized
you can do the same with the regex. (maybe someone already did it this way
with regex not sure)

  put field 1 into tVar
   put replacetext(tVar,"\ncreature[2-9]\d?\d?:",space) into tVar --will
match creature up to creature999
   put replacetext(tVar,"\nnotes[2-9]\d?\d?:",space) into tVar -- same for
notes up to 999

   put tVar into field 2

On Mon, Jan 30, 2012 at 8:10 PM, Michael Kann <mikekann at yahoo.com> wrote:

> Sorry, I forgot the colons.
>
> 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, Michael Kann <mikekann at yahoo.com> wrote:
>
> From: Michael Kann <mikekann at yahoo.com>
> Subject: Re: Combining some lines of text in a list?
> To: "How to use LiveCode" <use-livecode at lists.runrev.com>
> Date: Monday, January 30, 2012, 9:01 PM
>
> 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
> _______________________________________________
> 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
> _______________________________________________
> 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