Re: Recommendations for AppleScript Formatting
Re: Recommendations for AppleScript Formatting
- Subject: Re: Recommendations for AppleScript Formatting
- From: Shane Stanley <email@hidden>
- Date: Thu, 25 Oct 2001 16:10:01 +1000
At 11:18 -0700 10/24/2001, Mark Alldritt wrote:
>
Note that in SD3, the AppleScript formatting settings are scriptable, so you
>
can write a script that saves your preferred settings, applies settings
>
suitable for export, run the HTML export and finally restore your preferred
>
settings.
And if, for example, you use a unique color for variables, you can quickly
(well, depending on the size of the script...) build a list of those used in
a script:
set newVariables to {}
set searchProperty to color of (get item 7 of AppleScript formatting) --
assumes unique color
with timeout of 200 seconds
set allVariables to every word of script document 1 whose color =
searchProperty
end timeout
repeat with aVariable in allVariables
if newVariables does not contain aVariable then
set end of newVariables to contents of aVariable
end if
end repeat
set newVariables to my quicksort(1, count newVariables, newVariables)
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set newVariables to newVariables as text
set AppleScript's text item delimiters to oldDelims
make new script document
set contents of result to newVariables
on quicksort(begin, ending, theList)
copy begin to leftValue
copy ending to rightValue
copy item ((begin + ending) div 2) of theList to startValue
repeat until rightValue > leftValue
repeat while item leftValue of theList < startValue
copy leftValue + 1 to leftValue
end repeat
repeat while item rightValue of theList > startValue
copy rightValue - 1 to rightValue
end repeat
if leftValue > rightValue then
copy item leftValue of theList to tempVar
copy item rightValue of theList to item leftValue of theList
copy tempVar to item rightValue of theList
copy leftValue + 1 to leftValue
copy rightValue - 1 to rightValue
end if
end repeat
if begin < rightValue then tell me to quicksort(begin, rightValue, theList)
if ending > leftValue then tell me to quicksort(leftValue, ending, theList)
return theList
end quicksort
--
Shane Stanley, email@hidden