Colorize Script

FlexibleLearning at aol.com FlexibleLearning at aol.com
Thu Apr 15 03:51:30 EDT 2004


Derek:


> >The Scripter's Scrapbook will colorize selected text for you if you choose
> >'Colorize' from the 'Entries' menu. If you need to roll your own, look at
> the mc
> >script which should give you a good starting point.
> 
> I wish I could, but the script is password protected.  If you could help me
> out with this then that would be great.
> 

See 'on colorizescript' in the card script of MC's script editor window...

on colorizescript
  if tokencolors["if"] is empty then setupcolors
  local s
  put field "Editor Field" into s
  put s into field "Editor Field"
  go to card 2
  local curword
  put 1 into curword
  repeat for each word w in s
    if tokencolors[w] is not empty
    then set the textColor of word curword of field "Editor Field" of card 1 
to tokencolors[w]
    add 1 to curword
  end repeat
  local oldline, cline, curline, nwords
  put min(lineoffset("#", s), lineoffset("--", s)) into oldline
  put 0 into cline
  repeat while oldline is not 0
    add oldline to cline
    put line cline of s into curline
    put the number of words in curline into nwords
    repeat with curword = 1 to nwords
      if char 1 of word curword of curline is "#" or char 1 to 2 of word 
curword of curline is "--" then
        set the textColor of word curword to nwords of line cline of field 
"Editor Field" of card 1 to "DarkOrchid4"
        exit repeat
      end if
    end repeat
    put min(lineoffset("#", s, cline), lineoffset("--", s, cline)) into 
oldline
  end repeat
  go to card 1
  unlock screen
end colorizescript

on setupcolors
  repeat for each word w in the commandNames
    put "blue" into tokencolors[w]
  end repeat
  repeat for each word w in "if then else repeat for with while on end switch 
case getprop setprop"
    put "Brown" into tokencolors[w]
  end repeat
  repeat for each word w in the functionNames
    put "DarkOrange" into tokencolors[w]
  end repeat
  repeat for each word w in the propertyNames
    put "red" into tokencolors[w]
  end repeat
end setupcolors


_________________________________________________
Hugh Senior
The Flexible Learning Company
Consultant Programming & Software Solutions
Fax/Voice: +44 (0)1483.27 87 27
Email: mailto:h at flexibleLearning.com
Web: www.flexibleLearning.com


More information about the use-livecode mailing list