Target not working???

Mark Wieder mwieder at ahsoftware.net
Tue Mar 28 18:04:31 EST 2006


David-

Tuesday, March 28, 2006, 3:09:47 AM, you wrote:

> I really can't see that I am "fighting the "natural" object
> hierarchy". The loop (or something like it needs) to be held  
> somewhere, the fact that it is held in a "central" place really  
> doesn't make much difference. In your example I'd need N loops, one
> for each stack, doing it my way just results in one loop, e.g. less
> code. Of course you could make a common function out of your loop and
> store it in the Stack Script or in a Library and then just call it  
> from each object. This wouldn't be "fighting the "natural" object  
> hierarchy", so how can putting in *my* library be different?

No.

It's tested now. The loop goes in the library stack. One loop. Then it
gets called on openStack. One line of code per stack. You don't "call"
it from each object, you send the message to the object from the loop.
If it's not overloaded in the object it falls through to the library
stack. That's OOP in action. The fact that it's in a library stack
makes all the difference. And it's fast because there's no need to
scan the object scripts.

--in library
on InitializeEvents
 local x
 repeat with x=1 to the number of controls
   send "ISM_InitializeObject" to control x
 end repeat
end InitializeEvents

on ISM_InitializeObject
  -- we get here if there no ISM_InitializeObject
  -- handler in the control.
  -- do the default stuff here
end ISM_InitializeObject

--in each stack
on openStack
  InitializeEvents
end openStack

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the Use-livecode mailing list