Main menu puzzle

Kay C Lan lan.kc.macmail at gmail.com
Sat Feb 18 06:39:30 EST 2006


On 2/18/06, Ken Apthorpe <ken.apthorpe at optusnet.com.au> wrote:
>
>
> Hi anyone
>
> SHORT VERSION (immediate problem)
>
> Created my first menu, using menu builder and autoscript. Ungrouped to
> look
> at scripts.  File menu has Exit, divider and Quit (for Mac shift). Script
> is:
>
> --The following menuPick handler was generated by the Menu Builder.
> on menuPick pWhich
>   switch pWhich
>   case "Exit"
>     --Insert script for Exit menu item here
>     break
>   case "Quit"
>     --Insert script for Quit menu item here
>     break
>   end switch
> end menuPick
>
> After exploration to discover an Exit/Quit script, my script is:
> on menuPick pWhich
>   switch pWhich
>   case "Exit"
>   on "Exit" answer "Are you sure you want to exit?" with "Yes" or "OK"
>      if it is "OK" then quit
> end "Exit"
> break
>   case "Quit"
>   on "Quit" answer "Are you sure you want to quit?" with "Cancel Quit" or
> "OK"
>       if it is "OK" then quit
> end "Quit"
> break
>   end switch
> end menuPick
>
> Error window says error, hint "on".



on "Exit" answer "Are you sure you want to exit?" with "Yes" or "OK"

should be just:
 answer "Are you sure you want to exit?" with "Yes" or "OK"

the line - case "Exit" is basically saying on Exit.

>From here I guess you can figure out what is wrong with the on "Quit"
line:-)

pWhich is a paramater passed when you make a selection - it could easily be
pTheMenuSelectionImade, in the documents I think they use theMenuItem (I
typed 'on menuPick' into Preview's search field and found the info in half
an eye blink - I love these new docs) so it really doesn't matter what you
call it so long as you pass the same name into the 'switch' control
structure.

HTH



More information about the use-livecode mailing list