Page 1 of 1

changing menupick item action depending on current card

Posted: Thu Oct 09, 2008 4:33 pm
by Martin Koob
I have a menu item in a menu that performs different actions depending on which card is the current card. I thought I could do this by using 'this card' to determine the current card and run the correct command.

Code: Select all

on menuPick pWhich
   switch pWhich
    
      case "Open Project File..."

      If this card  is "browse" then
         Send "mouseup" to button "Open Project"
       else if this card  is "record" then
           Send "mouseup" to button "recordOpenProject"
        end if
      break
     case "New Project file..."
         ....
      break
If I run that I get the following error.

Type Chunk: source is not a container
Object File
Line If this card is "browse" then
Hint menuPick
I have tried the same script with

Code: Select all

'If the current card  is "browse" then'
...
and get a similar error message.

How do I determine in a menu script what the current card is. Any suggestions?
[/code]

Posted: Thu Oct 09, 2008 4:59 pm
by Klaus
Hi Martin,

you are looking for "the short name of this cd" :-)

Code: Select all

on menuPick pWhich
   put the short name of this cd into name_o_cd
   switch pWhich    
      case "Open Project File..." 
      switch name_o_cd
          case "browse" 
             Send "mouseup" to button "Open Project" 
          break
          case "record" 
             Send "mouseup" to button "recordOpenProject" 
          break
       end switch
      ## I prefer "switch" instead of unreadable nested "it...then" structures ;-)

      break 
     case "New Project file..." 
         .... 
      break 
Best

Klaus

Posted: Fri Oct 10, 2008 1:06 am
by Martin Koob
Thanks Klaus, that did the trick.

Martin