Date: Tue, 21 Apr 1998 18:03:47 +0200 From: Paul <pool_oeks@hotmail.com> Subject: Lingo FormattingI must be a fool giving this code away. I should let you all pay for it!
This handler turns your scripts into formatted text. In its original form, all handler-definitions become BOLD, comments become ITALIC and global definitions become blue. But you can always add more features, or change the styles.
-- formatScript: creates formatted scripts for easier reading and programming!
-- This way, you don't need Xtras like ScriptOMatic!
on formatScript scriptNr
if the type of member scriptNr = #script then
set script to the scriptText of member scriptNr
set nLines to the number of lines in script
-- first, put the handlername after every "end"-statement
if nLines then
set handlerName to ""
repeat with l=1 to nLines
set theLine to line l of script
if theLine starts "on" then
set handlerName to word 2 of theLine
end if
if theLine starts "end" then
set theString to line 1 to (l-1) of script
put RETURN & "end " & handlerName & RETURN after theString
put line (l+1) to nLines of script after theString
set script to theString
set handlerName to ""
end if
end repeat
-- now, format the script
set the scripttext of member scriptNr to script
set the fontStyle of script scriptNr to "plain"
repeat with l=1 to nLines
set theLine to line l of script
-- comments become italic
if theLine contains "--" then
set start to offset("--",theLine)
set stop to length(theLine)
if not (start>1 and char (start-1) of theLine = QUOTE) then
set the fontStyle of char start to stop of Â
line l of script scriptNr to "italic"
end if
end if
-- handlerdefinitions become bold
if theLine starts "on" then
set the fontStyle of line l of script scriptNr to "bold"
-- globals definitions become blue (on PC. Use another number on Mac.)
else if theLine starts "global" then
set the foreColor of line l of script scriptNr to 3
end if
end repeat
end if
end if
end formatScript