------------------------------------------------------------------------------------------------
# Author: Christopher Stone
# Created: 2012-05-01 : 02:54
# Modified: 2012-05-01 : 03:20
# Application: Script Debugger
# Purpose: Finder variables in the front document and present a choose-from dialog.
# Dependencies: Satimage.osax
------------------------------------------------------------------------------------------------
on cng(findText, changeText, srcData)
return change findText into changeText in srcData with regexp without case sensitive
end cng
------------------------------------------------------------------------------------------------
on fnd(findStr, srcData, caseSensitive, allOccurrences, stringResult) # Normally in a library
return find text findStr in srcData case sensitive caseSensitive all occurrences allOccurrences ¬
string result stringResult with regexp
end fnd
------------------------------------------------------------------------------------------------
on fndUsing(fndStr, returnStr, srcData, caseSensitive, regExFlag, wholeWord, allOccurrences, stringResult)
return find text fndStr in srcData case sensitive caseSensitive regexp regExFlag ¬
whole word wholeWord using returnStr all occurrences allOccurrences string result stringResult
end fndUsing
------------------------------------------------------------------------------------------------
set varList to {}
tell application "Script Debugger"
if document 1 exists then
tell document 1
set srcText to source text
# Handlers
set handlerList to fndUsing("^on ([^\\(]+[^\\)]*\\))", "\\1", srcText, false, true, false, true, true) of me # Strip Comments
set srcText to cng("^\\s*(?:(--|#)).+\\s*", "", srcText) of me
# Strip Strings
set srcText to cng("\".+\"", "", srcText) of me
# Mixed Case with or without Underscores - upper or lower case with embedded underscores.
# Beginning or ending with underscore
set pickList to sortlist varList comparison 1 with remove duplicates
if length of handlerList > 0 then
set pickList to {"----- VARIABLES -----"} & pickList & "----- HANDLERS -----" & handlerList
end if
set pickList to choose from list pickList with title ¬
"List of Variable & Handler List" with prompt ¬
"Pick One or More:" default items (item 1 of varList) ¬
multiple selections allowed true ¬
with empty selection allowed
if pickList is not {} and pickList is not false then
set AppleScript's text item delimiters to return
set pickList to pickList as text
set selection to pickList
end if
end tell
else
beep
end if
end tell
------------------------------------------------------------------------------------------------