Main menu puzzle

Alex Tweedly alex at tweedly.net
Sat Feb 18 08:57:13 EST 2006


Ken Apthorpe wrote:

>Alex
>You say:
>on menuPick pWhich 
>    switch pWhich 
>        case "Exit" 
>            answer "Are you sure you want to exit?" with "Yes" or "OK" 
>            if it is "OK" then quit 
>            break 
>        case "Quit" 
>           answer .... 
>           if it is "OK" then ... 
>           break 
>    end switch 
>end menuPick
>
>I'm sure this would work.  Problem is, I don't understand why.  This isn't
>your problem, you've given me a solution which is more than I could expect,
>thank you.
>
>  
>
Well, what I did was show you the fixed version of the switch control 
structure .... I left the code within it unchanged.

>My problem with this script is:  it produces two choices, Yes or No. Buttons
>I assume.  OK is handled.  Yes does not appear to be handled by anything. 
>But, if it works it must be handled somehow.  But there is nothing in this
>script (that I can see) to cater for a choice of Yes.
>
>It's a dilemma.  You say this works. I believe you (on faith, not having
>tried it). 
>
As I said, I didn't change your code within the structure, so it may not 
work (sorry about that - see below).

>But I can't see how it can possibly work, because there is
>nothing that appears to handle a choice of Yes.  Isn't programming supposed
>to follow the script?
>
>  
>
You don't necessarily need to handle all possible cases - e.g. if there 
is nothing to do.
The code could have been
  answer "Really quit?" with "Yes" or "No"
  if it = "Yes" then quit

If the answer is "No", then you don't quit - so nothing needs to be done !


I've now done what I should have done in the first place ----
look in RevOnline, under username alextweedly there is a script called
 "Menu script for quit"
which has a working, tested script in it !  I'll fill in all the rest of 
it later (e.g. some help info, more comments, etc") but I wanted to get 
this very skeletal version up where you could read it asap.

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17/02/2006




More information about the use-livecode mailing list