Repeat for each line?
Magnus von Brömsen
webmaster at studioalice.se
Thu Apr 18 06:20:01 EDT 2002
Thanks Jeanne,
for your fast and excellent help!
It works great. So far I have only tried the first one (the field
contains max 50 lines). But I will try the others later.
Thanks.
Magnus
On torsdag, april 18, 2002, at 12:16 , Jeanne A. E. DeVoto wrote:
> At 1:06 AM -0700 4/18/2002, Magnus von Brömsen wrote:
>> on addOrder
>> repeat for each line x in field "articles"
>> if the foregroundColor of x = 204,0,0 then
>
> The problem here is that when you use this form of the repeat loop, your
> variable "x" contains the actual text of the line. And a variable has no
> foregroundColor as such - it's just the line contents - so no go. It's
> like
> saying "if the foregroundColor of "foo" is 204,0,0".
>
> Here's one alternative:
>
> on addOrder
> repeat with x = 1 to the number of lines of field "articles"
> -- with this form, "x" is the line number, not the contents
> if the foregroundColor of line x of field "articles" is "204,0,0"
> then put line x of field "articles" & return after redLine
> end repeat
> put redLine into field "order"
> end addOrder
>
> That is pretty straightforward - you're checking every line in the
> field,
> in order - but it is not very efficient. If the field "articles" has a
> lot
> of lines, more speed may be needed. Here's another way that should be
> faster:
>
> on addOrder
> repeat for each line thisLine in the htmlText of field "articles"
> -- "thisLine" contains the htmlText, and the htmlText contains
> -- tags for all the formatting, so you can check it for color:
> if "font color="#CC0000" is in thisLine
> then put thisLine & return after redLine
> end repeat
> set the htmlText of field "order" to redLine
> -- include the next line if you want to remove formatting from
> -- the "order" field (formatting is still there because you used
> -- the htmlText):
> put field "order" into field "order"
> end addOrder
>
> --
> Jeanne A. E. DeVoto ~ jeanne at runrev.com
> Runtime Revolution Limited - The Solution for Software Development
> http://www.runrev.com/
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list