So for example, create a stack only stack named "Button Behaviors" with the following code
Code: Select all
on mouseUp
   getTarget
end mouseUp
command getTarget
   
   switch the owner of the target
      
      case "card id 1002"
         
         switch the target
            case "button " "e&"1""e
               answer "HI button 1 of card 1002"
               break
            case "button " "e&"2""e
               answer "HI button 2 of card 1002"
               break
            case "button " "e&"3""e
               answer "HI button 3 of card 1002"
               break
         end switch
         
         break
         
      case "card id 1006"
         
         switch the target
            case "button " "e&"1""e
               answer "HI button 1 of card 1006"
               break
            case "button " "e&"2""e
               answer "HI button 2 of card 1006"
               break
            case "button " "e&"3""e
               answer "HI button 3 of card 1006"
               break
         end switch
         
         break
         
   end switch
   
end getTargetThen create a normal stack with 2 cards make sure the card are named "card id 1002" and "card id 1006"
Add 3 buttons on each card named "1","2","3"
Add to the card script
Code: Select all
on openStack
   start using stack "Button Behaviors"
end openStackTesting for the owner of the target allows for the same named controls to be on multiple cards, so the above example has 2 cards, 6 buttons and 1 script only stack for all of the 6 button actions.
I haven't as yet had any problems with this method and it has reduced the number of scripts in my projects considerably.
So what do you think? Can you see any pitfalls or problems I might be building for the future?
 , should have seen the hand slapping coming for this one!
, should have seen the hand slapping coming for this one! 
   
  .
.
 , it's in case someone new to LC goes through this thread.
, it's in case someone new to LC goes through this thread. so many destinations can be reached via many routes. Previously to Livecode, I mainly programmed in Delphi - Pascal which was stricter but still used an English language like syntax.
 so many destinations can be reached via many routes. Previously to Livecode, I mainly programmed in Delphi - Pascal which was stricter but still used an English language like syntax.