I use a SUB program similar to this to change chapters in a demo. It will wait up to 2 seconds for another entry when a 1 is pressed.
SUB Entry (chp%) 'chp% returned to program
DO: A$ = INKEY$: LOOP UNTIL A$ = "" 'clear key buffer
DO: CH$ = INKEY$: LOOP UNTIL CH$ > CHR$(48) AND CH$ < CHR$(58) 'wait for first non-zero entry
start! = TIMER: dlay! = start! + 2 '2 second delay for second entry
DO:
IF CH$ = CHR$(49) OR done = 1 THEN 'if 1 is entered or second digit
IF CH$ > CHR$(47) AND CH$ < CHR$(51) THEN 'limit 0 to 2
one$ = one$ + CH$
done = done + 1 '2 if sec digit entered
END IF
ELSEIF CH$ > CHR$(49) AND CH$ < CHR$(58) THEN 'limit 2 to 9
LOCATE 20, 68: PRINT CH$ 'exit if entries above 1
chp% = VAL(CH$): EXIT DO 'convert to number? and quit
END IF
CH$ = INKEY$ 'get second digit?
LOCATE 20, 68: PRINT one$
chp% = VAL(one$) 'convert string to number value?
IF start! > TIMER THEN dlay! = dlay! - 86400 'midnite adjustment
LOOP UNTIL TIMER > dlay! OR done = 2
SLEEP 1 'allow user to view entry
A$ = INKEY$ 'clear SLEEP key buffer if used
END SUB
I set this up for numbers from 1 to 12 only. I convert it to a number value for a chapter in SELECT CASE. You could use the string value also.
OOPS! Edited LOCATE's for screen 0. I had screen 12.
Ted
This message has been edited by burger2227 on Mar 31, 2009 4:04 PM This message has been edited by burger2227 on Mar 31, 2009 3:19 PM
|
|