Main menu puzzle
Ken Apthorpe
ken.apthorpe at optusnet.com.au
Sat Feb 18 03:52:28 EST 2006
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".
LONG VERSION (working example of newbie problem)
First question is what does pWhich mean? Look in Rev Dictionary. Not
listed. Look under commands, parameters etc. Look in Scripters Scrapbook.
Look in tutorial stacks I've downloaded. Lots of pWhichs in scripts but no
explanations. Try a Google search (desperate). Get a bunch of links to Perl
programming.
OK, forget pWhich for the present, I need an Exit script. Here's an example
under quit in Dict:
on getMeOuttaHere
answer "Are you sure you want to quit?" with "No way" or "OK"
if it is "OK" then quit
end getMeOuttaHere
So, my script should be:
on menuPick pWhich
switch pWhich
case "Exit"--for Win
on "Exit" answer "Do you really want to exit?" with "No" or "OK"
if it is "OK" then quit
end "Exit"
break
case "Quit" --for Mac
on "Quit" answer "Do you really want to to quit?" with "No" or "OK"
if it is "OK" then quit
end "Quit"
break
end switch
end menuPick
But Errors says this script is wrong, and gives the Hint "on". How can it
be wrong if it's a script from Docs? Look up case and switch but those are
no help either. Look up "on". Don't understand any of the explanation.
In any event, if it worked this script would seem to create a dialogue box
with two buttons to choose from. OK is handled, but the No button doesn't
seem to be. So, it's not actually going to work anyway. So it's not a very
helpful example of a script IMHO.
Try elsewhere. Look at FirstStack pdf.... ah.. page 15 has a mouseUp script,
but maybe I can adapt bits of it. Here goes:
on menuPick pWhich
switch pWhich
case Exit
on "Exit" answer "Do you really want to Exit?" with "No" or "OK"
if it is "OK" then
quit
else if it is "No" then
pass menuPick --total guess here, could be pass pWhich or pass Exit
or?
end Exit
break
case Quit
on "Quit" answer "Do you really want to Quit?" with "No" or "OK"
if it is "OK" then
quit
else if it is "No" then
pass menuPick
end Quit
break
end switch
end menuPick
Error: Hint on Good try, but it doesn't pass go. Hmmm I've been at this
for about an hour now. But, no pain no gain.
Next try. Open the Revolution Scripting Conferences - Menus stack. Hmmm, it
doesn't have a main menu. Funny. A tutorial on menus that doesn't have a
main menu as an example. Click through. Lots of button menus that use
mouseUp handlers, but no main menus that use menuPick. Wait, here is a card
with a demo Menu bar stack for a Mac menu. Great, it will have menuPick
scripts I can look at. Open this substack, switch to Edit tool, ungroup the
menu, select File, open Script editor..... crikey..... this is an unscripted
menu with no scripts at all.
Last try. Open the Managing menus stack. Uh oh..... it's about building
on-the-fly menus. I just want a plain vanilla static menu. Maybe I can
understand this tutorial about a year from now.
Private thoughts I'll make public. I've now spent two hours trying to do
the right thing by giving Rev a go, experimenting, hunting thru the Docs,
looking at other people's stacks to see how they do it, and supposing that
somehow this would lead me to an understanding of Transcript.
The only thing I've discovered is that the very popular "pWhich" seems to
have failed to make it into the Dictionary.
I wonder why it seems so impossible for Rev to produce a tiny template stack
with a working main menu, and working scripts that are fully commented. By
fully, I mean with plain english (not "english-like") definitions and
explanations. This is the typical script example I see:
case "Exit"
--Insert script for Exit menu item here
--or the variation, Do stuff here...
break
This is fine for the experienced, but not helpful comments for newbies who
don't have a clue what to insert, or how to find the cause of an error.
I'm sure someone can point me at a working example. Pity it's been so hard
to find a Rev one.
Ken
--
View this message in context: http://www.nabble.com/Main-menu-puzzle-t1145446.html#a3003191
Sent from the Rev Pilgrim's Progress forum at Nabble.com.
More information about the use-livecode
mailing list