'=========================================================================== ' Subject: FILTER OUT CHOICES FROM LIST Date: 12-11-99 (12:41) ' Author: Terry Simonds Code: QB, QBasic, PDS ' Origin: fsimonds@gate.net Packet: MISC.ABC '=========================================================================== DECLARE SUB Continue () ' FILTER.BAS ' Returns a single key from a predermined list of choices. ' Allows the system clock to be ' used to display seconds while you're waiting at this screen. ' ' ********************************************************** ' * Written by Terry Simonds/WB4FXD fsimonds@gate.net * ' ********************************************************** ' ' ' The code in the main part of this is for demonstration only. ' Filtering is done in the Sub ' DECLARE SUB Filter () COMMON SHARED k$, k Start: COLOR 15, 1: CLS LOCATE 8, 10: PRINT TIME$ ' "NOT PART OF FILTER: FOR DEMO ONLY" LOCATE 10, 10 PRINT "Select Option ("; : COLOR 14, 1: PRINT "e"; : COLOR 15, 1 PRINT "dit "; : COLOR 14, 1: PRINT "d"; : COLOR 15, 1 PRINT "elete "; : COLOR 14, 1: PRINT "p"; : COLOR 15, 1 PRINT "rint)" ' ******************************************************************** k$ = "PDE+Q": Filter 'k$ defines the permissable choices ON k GOTO Prnt, Dele, Edit, Enter, Quit 'Steering after valid choice ' ******************************************************************** ' ' The above, with the sub, is the guts of the thing Prnt: LOCATE 12, 10 PRINT "You chose to Print... ("; k$; "), position"; k Continue GOTO Start Dele: LOCATE 12, 10 PRINT "You chose to Delete... ("; k$; "), position"; k Continue GOTO Start Edit: LOCATE 12, 10 PRINT "You chose to Edit... ("; k$; "), position"; k Continue GOTO Start Enter: LOCATE 12, 10 PRINT "You hit the Enter key... ( CHR$(13) ), position"; k Continue GOTO Start Quit: LOCATE 12, 10 PRINT "You chose to quit... ("; k$; "), position"; k END SUB Continue LOCATE 14, 10 COLOR 12, 1 PRINT "Press any key to restart... (q to quit)" COLOR 15, 1 DO LOCATE 8, 10: PRINT TIME$ ' "NOT PART OF FILTER: FOR DEMO ONLY" LOOP UNTIL INKEY$ <> "" END SUB SUB Filter IF INSTR(k$, "+") > 0 THEN MID$(k$, INSTR(k$, "+"), 1) = CHR$(13) 'The "+" sign allows the "Enter" (Chr$(13) key to be valid 'as well as the listed choices. Use when you want "Enter" to 'be the default to, say, a "Yes" or an "OK" choice. TryAgain: DO: trap$ = UCASE$(INKEY$) LOCATE 8, 10: PRINT TIME$ ' "NOT PART OF FILTER: FOR DEMO ONLY" LOOP WHILE trap$ = "" ' IF INSTR(k$, trap$) THEN 'If the keystroke was on on the list k = INSTR(k$, trap$) 'then exit the sub with the key k$ = RIGHT$(trap$, 1) 'that was hit and its position EXIT SUB 'in the permissible-choice string (k$) END IF GOTO TryAgain 'Wrong key--try again END SUB