Susan Semanck & C Marshall Curtis
Making selections from a complicated menu can be made easier and faster in a number of ways. This is Part 5 in a series on developing a communications program for the handicapped. The programs, for the PET and VIC, demonstrate various methods of active and passive entry selection. These programs are easily adapted to any computer using Microsoft BASIC.
Once a menu is displayed, procedures must be considered for selecting an entry of the menu. This can be done passively, where the computer controls positioning and the user controls selecting, or actively, where the user controls both positioning and selecting. In a passive approach, the computer points to each menu entry individually, pausing for a predetermined amount of time based on the user's ability to respond. If no response is made during the pause, then the computer continues to scan the menu sequentially.
Passive interaction is good for persons with severe motor impairment, since a single movement can indicate the user's response. But, depending on the size of the menu, the computer can take time to point to a desired menu entry. Different types of scanning techniques can speed up a passive selection process.
In an active selection procedure, the user indicates the position of the menu entry. This is the way we've selected a menu entry in our program examples so far, by having the user type the entry's row and column numbers to make a selection. Another method for this procedure is to use an alternative input device, such as a joystick, to control a pointer on the screen. When the pointer has been moved opposite the desired menu entry, the joystick's button could be used to indicate that a selection is desired.
Program 1 is a passive selection algorithm that can replace lines 300-360 in any of the previous examples (April 1983) that allowed selection of a menu entry. Hitting any key during the pause time will select the indicated menu entry and place it in the message area of the screen. The format we're displaying has two top screen lines reserved for input functions (to be discussed in a later article), middle lines for the menu, and sufficient bottom lines for a message of 160 characters. Review part two of this series (June 1982) if a different menu setup is desired.
Program 1 shows how an arrow can be used on the PET computer to indicate that a menu entry is being scanned. Since the entries in a column have various lengths less than or equal to the column's width, it is necessary to calculate each entry's length for proper spacing in the message area. This is accomplished in lines 312 and 314 by the variable E. Line 530 embeds a space after each word entry placed in the message area. When we consider other user input options, we will provide a means of eliminating spaces between words and adding punctuation marks for those that need correspondence quality messages.
To make the message more readable on the screen, line 505 insures that no words will be split at the right-hand edge of the screen. So far, our routine works well if your menu is composed only of columns of individual words. But, if any column has rows of characters (as in our DAILY menu), our selection process will not recognize the individual characters, but will put the entire row into the message area. It will be easier to adjust for the selection of individual characters if we agree that all character columns will appear on the right-hand side of the screen.
If the number of such columns is to vary from menu to menu, then we will need to add another menu parameter, CC, which will give the number of character columns in the menu. For our DAILY menu, CC =1, and for our TIME menu, CC = 0. In Program 1 (April, p. 135) CC should be appropriately added to lines 20 and 330; and in Programs 2 and 3 (April, p. 135), to line 216.
Scanning Display Indicators
We will change the selection process in Program 1 so that if a selection of a character row is made, then a secondary scanning will be done within that row. We can do this easily for highlighting and flashing, but only with at least one blank line between menu rows when using the arrow indicator. Notice that neither the automatic embedding of spaces nor the prevention of word-splitting is used with character selections. If you always have a space as one of the characters in your column of characters, and if you plan ahead, these omissions should not be a problem.
When forming a word from a column of characters, you usually need multiple letter selections. This can be accomplished by scanning the character column until no more selections are made from it. Otherwise, in a sequential scanning procedure, there could be a considerable time delay between the selection of consecutive characters. After a character selection is made, you could continue the scan from the same character selected, from the start of the selected character's row, or from the start of the selected character's column. The last option gives the greatest flexibility, especially if the characters are arranged according to frequency of use. To achieve the first option, change line 465 to GOTO 444; for the second option, change line 465 to GOTO 442; and for the third option, change line 465 to K=1:RETURN, and add the following line:
318 IF K THEN K=0:R=1:GOTO 310
The improvements discussed for Program 1 have been incorporated in the following example. Program 2 employs an active user response procedure on a VIC computer, where a joystick is used to control the movement of a pointer and the joystick's button is used for selecting. A delay may be helpful; otherwise, multiple selections may unexpectedly result.
Try an arrow delay at line 465, a button delay at 470, and/or a character selection delay at 478, using FOR DE =1 TO 100:NEXT DE preceding the contents of the line(s) indicated. Notice that the original menu was shortened so the arrow could fit to the right of each column of the menu. Also, since the joystick routine can interfere with normal keyboard operation, be sure to push the RUN and RESTORE keys together to reset normal operations if the program is stopped in line 400.
PET Computer Using Arrow Indicator
299 REM DE=DELAY FOR PAUSE, PM=# OF POSITI
ONS IN MESSAGE AREA, J=CURRENT POS.
300 DE=100:SP=32768:HA=159:J=0:PM=200:REM ~
HA=SCREEN VALUE FOR HORIZONTAL ARROW
303 SM=SP+W*25-PM:VA=158:REM SCREEN VALUE ~
FOR VERTICAL ARROW
305 FOR C=1 TO CM: FOR R=1 TO RM
-1+L(C):REM PA=SCREEN POS. OF ARROW
315 POKE PA,HA:GOSUB400:POKEPA,32
320 NEXT R,C
399 REM USER RESPONSE ROUTINE
400 X=0: P=0
410 GET A$: IF A$<>""THEN 500
420 P=P+1: IF P<DE THEN 410
499 REM PUT SELECTION INTO MESSAGE AREA
500 P1=PA-L(C): P2=PA-1:REM P1=START OF EN
TRY, P2=END OF ENTRY
510 FOR I=P1 TO E:POKE SM+J,PEEK(I)
520 J=J+1:IF J=PM THEN J=0
530 NEXTI:POKESM+J,32:J=J+1:IF J=PM THEN J =0
For The Unexpanded VIC Computer
Note: This program uses a joystick in an active selection
process with an arrow indicator, character selection,
and different colors for the menu and message.
8 REM HIT RUN/RESTORE WHEN PROGRAM IS ST
9 REM DELETE REMARKS TO FIT PROGRAM ON U
10 PRINT CHR$(147);: REM CLEAR TEXT SCREE
1:CC=I:REM CC=# OF CHARACTER COLUMNS
25 DIM S(CM),L(CM):S(1)=SC
30 DATA 3,3,5,7:REM COLUMN WIDTHS/LAST ON
E SHORTENED TO FIT POINTER ON SCREEN
35 IF C=1 THEN 50
38 REM CALCULATE STARTING POSITION FOR EA
40 FOR I=2 TO CM:READ L(I-1):S(I)=S(I-1)+
L(I-1)+BC:NEXT I:READ L(CM)
50 IF SR--1 THEN 70
60 FOR X=1 TO SR-1:PRINT:NEXT X:REM POSIT
ION CURSOR TO FIRST ROW OF MENU
65 LP=S(CM)+L(CM)-1:IF LP>W THEN 200
70 TP=0:FOR R=1 TO RM:FOR C=1 TO CM:READ ~
80 PRINT TAB(P);M$;:NEXT C
90 IF S(CM)+LEN(M$)-1<W THEN PRINT:GOTO 1
00:REM WRAPAROUND ADVANCES A LINE
95 IF BR=0 THEN TP=TP+W:IF TP>87 THEN TP=
0:REM UPDATE TAB IF LINE ENDS W/NO LF
100 IF BR=0 THEN 120
110 FOR B=1 TO BR:PRINT:NEXT B:REM SKIP BL
ANK ROWS BETWN COLUMN ENTRIES
120 NEXT R
130 GOTO 300
140 DATA DR.,IS,COLD,INGEDS1
145 DATA I,AM,WHEN," AOTFR3"
150 DATA YOU,ARE,DRINK,.ULHCP5
160 DATA DAD,NO,TIME,",VJQZX9"
165 DATA HOT,YES,SLEEP,";$02468"
200 PRINT "MENU SIZE ERROR!":END
290 REM SP=STARTING MEMORY AREA FOR SCREEN
/CP=COLOR MAP FOR SCREEN
292 REM CL=MENU COLOR/HA=HORIZONTAL ARROW/
294 REM J=# OF POSITIONS USED IN MESSAGE A
:REM JOYSTICK REGISTERS
302 REM SM=STARTING POSITION FOR MESSAGE A
REA/PM=# OF POSITIONS IN MESSAGE AREA
303 SM=SP+W*23-PM:VA=158:MC=2:IF CL=2 THEN
CL=6:REM MC=RED MESSAGE COLOR
305 C=1:R=1:REM C=MENU COLUMN #/R=MENU ROW
311 REM P1=STARTING POSITION, P2=END OF CO
LUMN POSITION FOR MENU ENTRY
312 P1=PA-L(C):P2=PA-1:E=P2:FOR I=P2 TO P1
STEP-1:IF PEEK(I)<>32 THEN E=I:I=P1
313 REM E=ENDING POSITION FOR MENU ENTRY/P
A=SCREEN POSITION FOR HOR. ARROW
314 NEXT I
315 POKE PA,HA:POKE PA+CP,MC
320 GOSUB 400
330 IF Z=5 THEN 470
340 IF Z=4 THEN R=R+1
350 IF Z=3 THEN R=R-1
360 IF Z=2 THEN C=C+1
370 IF Z=1 THEN C=C-1
375 IF C<1 THEN C=1
377 IF R<1 THEN R=1
380 IF C>CM THEN C=CM
385 IF R>RM THEN R=RM
390 POKE PA,32:GOTO 310
399 REM WAIT FOR JOYSTICK MOVE OR BUTTON
400 Z=0:POKE XD,127:XV=PEEK(XR)AND128:POKE
XD,255:IF XV=0 THEN Z=2:GOTO 460
410 XV=PEEK(XL):IF (XVAND63)=63 THEN 460
420 IF (XVAND4)=0 THEN Z=3
430 IF (XVAND8)=0 THEN Z=4
440 IF (XVAND16)=0 THEN Z=1
450 IF (XVAND32)=0 THEN Z=5
460 IF Z=0 THEN 400
469 REM CHARACTER SELECTION
470 IF C<CM-CC+1 THEN GOSUB500:GOTO 320
472 I=PI:POKE PA,32
474 POKE I+W,VA:POKE I+W+CP,MC
476 GOSUB 400
478 IF Z<>5 THEN 484
480 Z=0:POKE SM+J,PEEK(I):POKE SM+J+CP,MC:
J=J+1:IF J=PM THEN J=0
482 GOTO 476
484 POKE I+W,32:IF Z=40RZ=3 THEN 340
486 IF Z=2 THEN I=I+1:IF I>E THEN 340
488 IF Z=1 THEN I=I-1:IF I<P1 THEN 340
490 GOTO 474
499 REM ADD SELECTION TO MESSAGE
504 REM NO WORD SPLITTING AT RIGHT EDGE OF
505 Y=W-(J-W*INT(J/W)+1):IF E-P1>=Y THEN J
=J+Y+1:IF J>=PM THEN J=0
510 FOR I=P1 TO E:POKE SM+J,PEEK(I):POKE S
520 J=J+1:IF J=PM THEN J=0
525 REM EMBED SPACE AFTER NON-CHARACTER SE
530 NEXT I:POKE SM+J,32:POKE SM+J+CP,MC:J=
J+1:IF J=PM THEN J=0