Page 1 of 1

why it deos not work?

Posted: Fri Jan 30, 2015 3:41 am
by keram
Hello,

I have to scripts to do the same thing - changing the text color of lines.

1 - this works OK

Code: Select all

      repeat for each line i in  fld "search_result_all_f" 
      if  lineOffset(i,gFavorites) > 0  then 
         Find i in fld "search_result_all_f"
         set the textColor of the foundLine  to "red"
      end if
      Find empty
   end repeat

2 - this does not work. Why?

Code: Select all

     repeat for each line i in  fld "search_result_all_f" 
      if  lineOffset(i,gFavorites) > 0  then 
         set the textColor of  line i in fld "search_result_all_f" to "red"
      end if
      Find empty
   end repeat
keram

Re: why it deos not work?

Posted: Fri Jan 30, 2015 3:47 am
by magice
When using "repeat for each"The value of i is not the line number. It is the line itself.

Re: why it deos not work?

Posted: Fri Jan 30, 2015 3:59 am
by keram
Thanks magice,

Corected the second one to:

Code: Select all

   repeat with   i  = 1 to the number of lines in  fld "search_result_all_f"
      if  lineOffset(i,gFavorites) > 0  then 
         set the textColor of  line i in fld "search_result_all_f" to "red"
      end if
   end repeat
Which way is faster 1 or 2?

keram

Re: why it deos not work?

Posted: Fri Jan 30, 2015 4:05 am
by dunbarx
Hi.

"Repeat for each" is MUCH faster than "repeat with...". But I do not see that you have made the "repeat for each" version. Do try it.

Craig Newman

Re: why it deos not work?

Posted: Fri Jan 30, 2015 4:09 am
by keram
Thanks Craig,
dunbarx wrote:But I do not see that you have made the "repeat for each" version.
Isn't the first one I posted "repeat for each"?

Re: why it deos not work?

Posted: Fri Jan 30, 2015 5:05 am
by dunbarx
Oh yes, you sure did.

Craig