Neat Trick!

Dave dave at looktowindward.com
Fri Mar 9 10:36:04 EST 2007


Hi All,

I was trying to make a Generic Menubar Stack, but had the old problem  
that the text changes depending on the name of the application, e.g.  
"About thisApp",  "About thatApp", ""About theOtherApp". Anyway, I  
tried the following code and it worked! I hadn't realized before that  
a parameter to a "case" clause can be a variable, which really makes  
it a lot more powerful.

Just thought I'd share!

All the Best
Dave

---------------------------------------------------------------
--
--  menuPick
--
---------------------------------------------------------------
on menuPick theItemSelected
   local myMenuItemNumber
   local myAboutMenuItemText
   local myAboutBoxStackLongName

   --
   --  Pull out the Text for the About Box Item
   --
   put line -1 of the text of me into myAboutMenuItemText
   delete char 1 of myAboutMenuItemText
   switch theItemSelected
   case myAboutMenuItemText

     --
     --  Go to the About Window
     --
     put ISMGetStackForService(kAppServiceAboutBox) into  
myAboutBoxStackLongName
     if myAboutBoxStackLongName <> empty then
       go to stack myAboutBoxStackLongName
     end if
     break

   case "Help"
     break

   end switch
end menuPick





More information about the use-livecode mailing list