Set the backgroundcolor of all lines a field to null

Richard Gaskin ambassador at fourthworld.com
Thu Aug 23 02:15:29 EDT 2018


Sannyasin Brahmanathaswami wrote:

 > I have some big lists in mobile,

How big is "big"? 100 lines?  1,000?  1,000,000?


 > I sent the bkgndColor of certain
 > lines.
 >
 > Then I want clear that,
 >
 > How do we do this "for each line x"
 > which does not return the number of the line, but value
 >
 > command setAudioListColors pLineNum,pColor  # pass "4,"0,0,0"
 > #slow!
 >       repeat with x=1 to (the number lines of fld "audioList")
 >           set the backgroundcolor of line pLineNum of fld "audioList" 
to pColor
 >     end repeat
 > repeat for each line x in fld "audioList"
 > # need to get a line number and not its value
 >   set the backgroundcolor of line pLineNum of fld "audioList" to pColor
 > end repeat
 > end setAudioListColors


Your command takes a line number and a color, and applies that color to 
that one line, yes?  If so, why loop at all?

As written, the code applies the color to the same line over and over 
for the number of lines in the field.

Maybe pLineNum could contain a list of line numbers?

If so, iterate through it rather than through the field, since chances 
are you're only setting the color of a subset of all lines in the field. 
Locking the screen first will speed that up even more.

But faster still will likely be to follow Brian's guidance on 
styledText.  With that you probably don't even want to lock the field, 
since all the changes are done in a variable outside the field, and the 
variable is set back into the field only once at the end.

But once we understand what's needed, the speed difference may not 
matter much. Or it might. It depends on how big "big" is.

If you want to clear everything at once:

   set the backgroundColor of line 1 to -1 of fld "audioList" to empty

All this is just guessing, though.  I'm not really sure what this 
handler should do.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list