# Edited according to Stan Cleveland comments.
set theScript to (path to desktop as text) & "work in progress 1.applescript" as alias
set itsText to read theScript as «class ut16»
set theProperties to {}
set maybe to my decoupe(itsText, "property ")
repeat with i from 2 to count maybe
set maybe2 to my decoupe(maybe's item i, space)
if item 2 of maybe2 starts with ":" then
set end of theProperties to item 1 of maybe2
end if
end repeat
theProperties # List of declared properties
set theHandlers to {}
set maybe to my decoupe(itsText, linefeed & "on ")
repeat with i from 2 to count maybe
set maybe2 to maybe's item i
set dropIt to false
repeat with unwanted in {"run", "open", "idle", "quit", "reopen", "error"}
if maybe2 starts with unwanted then
set dropIt to true
exit repeat
end if
end repeat
if not dropIt then
set end of theHandlers to item 1 of my decoupe(maybe2, "(")
end if
end repeat
theHandlers # list of handlers
set theGlobals to {}
set maybe to my decoupe(itsText, linefeed & "global ")
repeat with i from 2 to count maybe
set maybe2 to maybe's item i
if maybe2 does not contain ", " then
if maybe contains space then
set end of theGlobals to item 1 of my decoupe(maybe2, space)
else
set end of theGlobals to maybe2
end if
else
# we have several globals in the same instruction
# must drop possible comments
set maybe2 to item 1 of my decoupe(maybe2, {" #", " --", linefeed})
# grab the list of globals available in maybe2
set theGlobals to theGlobals & my decoupe(maybe2, ", ")
end if
end repeat
theGlobals
#=====
on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
#=====