List of handlers

Dick Kriesel dick.kriesel at mail.com
Sat Sep 10 02:41:46 EDT 2011


On Sep 9, 2011, at 4:50 PM, Chip Thomas wrote:

> Hey all, is there a way to get a list of handlers within a control?


Hi, Chip.

Here's a way that satisfies several goals you may find worthwhile:
1.  distinguish handler types (message, function, getProp, setProp)
2.  exclude commented-out handlers, even within block comments (/* … */)
3.  exclude redundant handlers
4.  include handlers in a behavior that the control references
5.  distinguish handlers in the control from handlers in the behavior

It's based on function "revListMenuHandlers" of card id 1002 of stack "revmenubar.rev"

Example usage:
put handlerList(long id of field "myField")

Be sure to compensate for email line wrapping after you copy and paste.

<script>

function handlerArray pObject, pIncludeBehavior
   local tObject, tHandlerArray, tBehavior
   if there is a pObject then
      put long name of pObject into tObject
      repeat for each line tHandler in the revAvailableHandlers of tObject
         put tObject into tHandlerArray[word 1 of tHandler][word 2 of tHandler]
      end repeat
      if pIncludeBehavior and (the behavior of tObject is not empty) and (there is a (the behavior of tObject)) then
         put long name of the behavior of tObject into tBehavior
         repeat for each line tHandler in the revAvailableHandlers of tBehavior
            if word 2 of tHandler is not among the keys of tHandlerArray[word 1 of tHandler] then
               put tBehavior into tHandlerArray[word 1 of tHandler][word 2 of tHandler]
            end if
         end repeat
      end if
      return tHandlerArray
   end if
end handlerArray

function handlerList pObject, pIncludeBehavior
   local tHandlerArray, tHandlerList
   put handlerArray(pObject, pIncludeBehavior) into tHandlerArray
   repeat for each key tHandlerType in tHandlerArray
      repeat for each key tHandlerName in tHandlerArray[tHandlerType]
         put tHandlerType && tHandlerName && tHandlerArray[tHandlerType][tHandlerName] & cr after tHandlerList
      end repeat
   end repeat
   sort tHandlerList by word 2 of each && word 1 of each
   return tHandlerList
end handlerList

<script/>

-- Dick



More information about the use-livecode mailing list