why it deos not work?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

why it deos not work?

Post by keram » Fri Jan 30, 2015 3:41 am

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: why it deos not work?

Post by magice » Fri Jan 30, 2015 3:47 am

When using "repeat for each"The value of i is not the line number. It is the line itself.

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: why it deos not work?

Post by keram » Fri Jan 30, 2015 3:59 am

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: why it deos not work?

Post by dunbarx » Fri Jan 30, 2015 4:05 am

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

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: why it deos not work?

Post by keram » Fri Jan 30, 2015 4:09 am

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"?
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: why it deos not work?

Post by dunbarx » Fri Jan 30, 2015 5:05 am

Oh yes, you sure did.

Craig

Post Reply