In the Sept/Oct 87 Sincus News, “A Cursor Pad” described how a home-made “Cursor Pad” (or a Joystick) could be used to move the cursor on the screen and thereby select one item from a list.
That demo program was valid only if the list did not exceed 20 items. This program will work with a list of any length.
The routine DISPLAY LIST, from 230 TO 250, breaks up the list into pages of no more than 19 items. It also adds “PAGE BACK” to the top of the page for pages after the first, and “PAGE FORWARD” to the bottom of the list for all but the last page.
The routine “SELECTOR”, from 200 to 222, uses input from the right-hand joystick port to move the cursor up and down the page. The firing button registers the selection. If the selection is either “PAGE BACK” or “PAGE FORWARD”, then another portion of the list appears on the screen.
If you prefer the keyboard to the joystick port, you need to change only two statements:
206 LET s2=CODE INKEY$: LET s1=1*(s2=55)+2*(s2=56)
+3*(s2=13)
216 IF s1=0 THEN GO TO 206
Now the 6 and 7 keys will control the motion of the expanded cursor, and ENTER determines the selection.
This SELECTOR routines differs in two respects from the one in the previous article. First: the cursor will jump from the top to the bottom of the displayed page (and vice-versa); this speeds the search for the proper page. Second: the motion of the cursor is limited by blank lines at the top and bottom of the display. This idea came to me from Chuck Dawson and/or Lafe McCorkle through a newsletter written by Ron Havlen for users of the Portuguese Disk System.
1 REM ** SELECTOR DEMO **
2
10 GO SUB 400
15
50 REM USE SELECTOR
60 GO SUB 230
70 CLS : PRINT A$(I): STOP
80
200 REM SELECTOR
202 LET m4=m2-m1+2: IF m1=1 OR m2=N THEN LET m4=m4-1
204 OVER 1: DIM s$(6): GO SUB 222
206 LET s1 = STICK (1,2): LET s2= STICK (2,2)
208 IF s1=2 AND SCREEN$ (i+1,0)<>" " THEN LET j=+1: GO TO 220
210 IF s1=2 THEN LET j=-m4: GO TO 220
212 IF s1=1 AND SCREEN$ (i-1,0)<>" " THEN LET j=-1: GO TO 220
214 IF s1=1 THEN LET j=+m4: GO TO 220
216 IF s2=0 THEN GO TO 206
218 OVER 0: RETURN
220 GO SUB 222: LET i=i+j: GO SUB 222: GO TO 206
222 PAUSE 5: PRINT AT i,0; INVERSE 1;s$: RETURN
225
230 REM DISPLAY LIST
232 LET m3=19: LET m1=1: LET m2=m3
234 CLS : IF m2>N THEN LET m2=N
236 LET m4=(m1=1): PRINT AT m4,0;" "
238 IF m1>1 THEN PRINT "PAGE BACK"
240 FOR j=m1 TO m2: PRINT A$(j): NEXT j
242 IF m2<N THEN PRINT "PAGE FORWARD"
244 LET i=2: GO SUB 200
246 IF i>1 AND i<m3+2 THEN LET i=i+m1-2: RETURN
248 IF i=m3+2 THEN LET m1=m2+1: LET m2=m2+m3: GO TO 234
250 IF i=1 THEN LET m2=m1-1: LET m1=m1-m3: GO TO 234
255
400 REM CREATE LIST
410 LET N=50: DIM A$(N,7)
420 FOR I=1 TO N
430 LET A$(I)="ITEM "+STR$ I
440 NEXT I: RETURN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.