The Queue:
Reformatting/regeneration ...
MRU: 09/03/05
Navigation
Index

About Me

Guestbook

Portfolio

Tutorials

Contact



Bunnie.net
The MENU Program
     We have worked with displays, variables, and If statements. Now, we will create a program that requires the user to interact with it. We will learn how to use menus. The command used to do this is, quite simply, the Menu( command. The format for this command is as follows:
Menu("MENU TITLE","MENU ITEM 1",1,"MENU ITEM 2",2, etc.

The code above would code for a menu that looks like the one below:
MENU TITLE
MENU ITEM 1 (taking you to label 1)
MENU ITEM 2 (taking you to label 2)

You may replace "MENU TITLE" (or any "MENU ITEM") with a title of your own choice, but if the name exceedes 16 characters, then it will trail off the screen. (Note: The corresponding labels to each of the menu items must exist, or else an error message will appear.)

Create a new program named MENU and type the following code into it.

:ClrHome
:Lbl 0
:Menu("WANT TO QUIT?","YES",1,"NO",2
:Lbl 1
:Stop
:Lbl 2
:Goto 0


     Now, execute your program. The program does not end unless you select the "NO" option of your menu. This is a very simple, but good, example of the use of menus. You will be using them extensively later on.
     One can also use the Input function to obtain data from the user. The form for the Input function is as follows: Input "Text",X. You can replace "Text" with whatever words you wish. Now that we know how to do that, let's add code to the MENU program so that it uses the Input function. Make it look like the code below:

:ClrHome
:Lbl 0
:Menu("WANT TO QUIT?","YES",1,"NO",2
:Lbl 1
:Disp " Use '1' and '2' "
:Input "ARE YOU SURE?",X
:If X=1
:Stop
:If X=2
:Goto 0
:Lbl 2
:Goto 0


     Execute your program. Notice that when you select "YES" in the menu, it takes you to the home screen and it poses a question. When you input '1', it ends the program; when you input '2', it acts like a cancel action and returns to the previous question.

Tutorial Contents
Index
Introduction
The HELLO Program
Enhancing the HELLO Program
The ONEPLUS1 Program
The Enhanced ONEPLUS1 Program
The MENU Program
The BOUNCE Program
The MOVEMENT Program
Other Helpful Info
 
 
 All content: © Bryan Aller 2005-2006