Classic Computer Magazine Archive COMPUTE! ISSUE 40 / SEPTEMBER 1983 / PAGE 261

Atari Menu Buttons

Joseph D. Korman

This utility streamlines the menu selection process by using the OPTION, SELECT, and START keys. The resulting program can be stored on tape or disk and can then be used as the beginning of new programs requiring menu selections.



    After catching the programming bug and purchasing an Atari 800, I began to write custom programs for home use. These included checking account, household inventory, telephone book, and the like. In all the programs, the menus ended with an input statement requesting the code for the desired choice. For example:

D. ENTER DEPOSIT
C. ENTER CHECKS
L. LIST CHECKS
S. SAVE REVISED DATA
ENTER NEXT FUNCTION:?

    After input of the variable, the program would run a series of IF tests to determine the choice and proceed to the indicated line number for execution. Although the programs worked well, I felt that something was missing to streamline the selection process. I found the answer in James Brunn's article in COMPUTE!'s First Book of Atari. The article included information about using the OPTION / SELECT / START buttons on the 800 keyboard.
    The menu create utility is actually a skeleton of a program designed to let the user move the cursor to each of the menu options by pressing the OPTION key. Once the cursor is at the line of the desired option; the SELECT key is used to move the program execution to the appropriate line. After the skeleton is loaded, the titles and option names should be changed to reflect the requirements of the new program. After this is done, the programmer need only enter the logic of the options and commands to return to the menu after their execution.
    The following program provides ten options starting on line five (5) and printing on each odd line. The user may add more selections to this column and may add a second column to the right side of the screen. If this is done, some changes in the cursor movement logic will be required. This will allow the user to make truly custom menus for the Atari 400/800 programs.
    The -] is printed in reverse mode and moves down each time the OPTION button is pressed.
    The menu created by this program looks like this on the screen:


"TITLE OF MENU"
-]  
ITEM 1

ITEM 2

ITEM 3

ITEM 4

ITEM 5

ITEM 6

ITEM 7

ITEM 8

ITEM 9

ITEM 10

    Each time the OPTION button is pressed, the arrow moves down the menu one position. Holding the OPTION button causes the arrow to continuously move from top to bottom and jump back to the top. The operator releases the button when the arrow is adjacent to the desired option. The SELECT button is then pressed to execute that part of the program.

Menu Buttons
1 REM {REV}MENU CREATE UTILITY{OFF}
10 GRAPHICS 0:SETCOLOR 2,2,8:SETCOLO
   R 1,2,0
11 POKE 752,1
20 POSITION 12,1:? "{REV}TITLE OF MENU{OFF}"
21 POSITION 2,3:? "{3 SPACES}ITEM 1••
22 POSITION 2,5:? "{3 SPACES}ITEM 2••
23 POSITION 2,7:? "{3 SPACES}ITEM 3"
24 POSITION 2,9:? "{3 SPACES}ITEM 4"
25 POSITION 2,11:? "{3 SPACES}ITEM 5
   "
26 POSITION 2,13:? "{3 SPACES}ITEM 6
   "
27 POSITION 2,15:? "{3 SPACES}ITEM 7
   "
28 POSITION 2,17:? "{3 SPACES}ITEM 8
   "
29 POSITION 2,19:? "{3 SPACES}ITEM 9
   "
30 POSITION 2,21:? "{3 SPACES}ITEM 1
   0"
31 REM POSITION ENTRIES ON ALL LINES
    TO INCREASE THE NUMBER OF SELECT
   IONS
35 POSITION 2,3:L=3:? "{REV}->{OFF}"
40 IF PEEK(53279)=3 THEN 50
41 IF PEEK(53279)=5 THEN 60
42 IF PEEK(53279)=6 THEN RUN
43 GOTO 40
50 REM {REV} MENU SCROLL{OFF}
51 POSITION 2,L
52 ? "  "
53 L=L+2:REM USE L+1 IF ENTRIES ARE
   ON ALL LINES
54 IF L=23 THEN L=3
55 POSITION 2,L:REM FOR TWO COLUMN M
   ENU POSITION 21,L AND ADD LOGIC T
   O RETURN TO LEFT COLUMN FROM HOT
   RT
56 ? "{REV}->{OFF}":FOR T=1 TO 40:NEXT T:REM U
   SE HIGHER NUMBER TO SLOW {REV}->{OFF}
57 GOTO 40
60 REM {REV}SELECT OPTION{OFF}
61 IF L=3 THEN 100
62 IF L=5 THEN 200
63 IF L=7 THEN 300
64 IF L=9 THEN 400
65 IF L=11 THEN 500
66 IF L=13 THEN 600
67 IF L=15 THEN 700
68 IF L=17 THEN 800
69 IF L=19 THEN 900
70 IF L=21 THEN 1000
71 IF L=23 THEN L=3:GOTO 61
72 REM ADJUST THE ABOVE LOGIC FOR SI
   NGLE LINE SELECTIONS AND DUAL COL
   UMN MENUS
100 GRAPHICS 0:SETCOLOR 2,1,2:SETCOL
    OR 1,1,8
110 POSITION 12,1:? "{REV}ITEM NUMBER 1{OFF}"
115 REM PUT LOGIC FOR THE SELECTION
    HERE
116 REM DON'T FORGET LOGIC TO RETURN
     TO THE MAIN MENU AFTER THE SELE
    CTION IS COMPLETED
117 REM CONTINUE FOR ALL OTHER SELEC
    TIONS
120 FOR T=1 TO 500:NEXT T:RUN
200 GRAPHICS 0:SETCOLOR 2,8,2:SETCOL
    OR 1,8,8
210 POSITION 12,1:? "{REV}ITEM NUMBER 2{OFF}"
220 FOR T=1 TO 500:NEXT T:RUN•
300 GRAPHICS O:SETCOLOR 2,8,8:SETCOL
    OR 1,8,2
310 POSITION 12,1:? "{REV}ITEM NUMBER 3{OFF}"
320 FOR T=1 TO 500:NEXT T:RUN
400 GRAPHICS 0:SETCOLOR 2,4,8:SETCOL
    OR 2,4,2
410 POSITION 12,1:? "{REV}ITEM NUMBER 4{OFF}"
420 FOR T=1 TO 500:NEXT T:RUN
500 GRAPHICS 0:SETCOLOR 2,11,8:SETCO
    LOR 2,11,2
510 POSITION 12,1:? "{REV}ITEM NUMBER 5{OFF}"
520 FOR T=1 TO 500:NEXT T:RUN•
600 GRAPHICS 0:SETCOLOR 2,1,2:SETCOL
    OR 1,1,8
610 POSITION 12,1:? "{REV}ITEM NUMBER 6{OFF}"
620 FOR T=1 TO 500:NEXT T:RUN
700 GRAPHICS 0:SETCOLOR 2,8,2:SETCOL
    OR 1,8,8
710 POSITION 12,1:? "{REV}ITEM NUMBER 7{OFF}"
715 IF L=23 THEN L=3:GOTO 61
720 FOR T=1 TO 500:NEXT T:RUN
800 GRAPHICS 0:SETCOLOR 2,8,8:SETCOL
    OR 1,8,2
810 POSITION 12,1:? "{REV}ITEM NUMBER 8{OFF}"
820 FOR T=1 TO 500:NEXT T:RUN
900 GRAPHICS 0:SETCOLOR 2,4,8:SETCOL
    OR 2,4,2
910 POSITION 12,1:? "{REV}ITEM NUMBER 9{OFF}"
920 FOR T=1 TO 500:NEXT T:RUN
1000 GRAPHICS 0:SETCOLOR 2,11,8:SETC
     OLOR 2,11,2
1010 POSITION 12,1:? "{REV}ITEM NUMBER 10{OFF}"
     "
1020 FOR T=1 TO 500:NEXT T:RUN