key problem
key problem
here is what i want to do in half human half qb language:
DO
key$ = INKEY$
LOOP UNTIL key$ = "q" or "w" or "e" or "r"
The problem is that i could only use 'or' once. What options do i have to get the same effect?
DO
key$ = INKEY$
LOOP UNTIL key$ = "q" or "w" or "e" or "r"
The problem is that i could only use 'or' once. What options do i have to get the same effect?
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
Like this:
Notice you need Key$ on each check....
Note: UCASE$ just makes everything capital and case insencitive...
Code: Select all
DO
Key$ = UCASE$(INPUT$)
LOOP UNTIL Key$ = "Q" OR Key$ = "W" OR Key$ = "E" OR Key$ = "R"
Note: UCASE$ just makes everything capital and case insencitive...
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
(x.t.r.GRAPHICS)
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
Waiting for a release of a key:
Code: Select all
While inkey$ = ""
WEND
While inkey$ <> ""
key$ = inkey$
WEND
Print "You pressed and released the ";key$;" key."
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
Um.. that doesn't work,.. it needs to be:
Or this:
Code: Select all
While key$ = ""
key$ = inkey$
WEND
Print "You pressed and released the ";key$;" key."
Code: Select all
DO
key$ = INKEY$
LOOP UNTIL key$ <> ""
PRINT "You pressed: "; key$
SLEEP
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
(x.t.r.GRAPHICS)
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
Here... I made a OUTKEY$ routine,.. works if you use a delay... INKEY$ is all jumpy, so with out it, it messes up a lil:
Code: Select all
DECLARE FUNCTION OUTKEY$ ()
DO
T! = TIMER
Press$ = INKEY$
Release$ = OUTKEY$
LOCATE 1, 1: PRINT "Pressed: "; Press$; " Released: "; Release$; " "
DO: LOOP UNTIL (TIMER - T!) >= .2
LOOP UNTIL Press$ = CHR$(27)
FUNCTION OUTKEY$
STATIC PRESS001
STATIC WAITKEY001$
KEY001$ = INKEY$
IF PRESS001 <> 1 AND KEY001$ <> "" THEN PRESS001 = 1: WAITKEY001$ = KEY001$': OUTKEY = ""
IF PRESS001 = 1 AND KEY001$ = "" THEN OUTKEY$ = WAITKEY001$: PRESS001 = 0
END FUNCTION
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
(x.t.r.GRAPHICS)
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
WEND works with WHILE to form a loop:
I normaly just use DO..LOOP,...
btw, my function copied and pasted into QB would be out of the way, all you need to do to use it is:
Like you would with INKEY$..
Code: Select all
WHILE X = 1
'Code here
WEND 'loop until X <> 1
btw, my function copied and pasted into QB would be out of the way, all you need to do to use it is:
Code: Select all
UKey$ = OUTKEY$
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
(x.t.r.GRAPHICS)
- The Awakened
- Veteran
- Posts: 144
- Joined: Sun Aug 07, 2005 1:51 am
Code: Select all
DO
t = t - 1
IF t = 1 THEN EXIT LOOP
b = b - 1
LOOP UNTIL b = 1
"Sorry for beating you up with a baseball bat Julian, but I DID think that you were a samsquanch."
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
Hmm... like this:
Code: Select all
SCREEN 13
x = 160 'Center of screen
DO 'Main loop
press$ = UCASE$(INKEY$) 'Look for keypresses
IF press$ = "A" THEN x = x - 1 'If a, move left
IF press$ = "S" THEN x = x + 1 'If s, move right
PSET(X, 100), 10 'Put object on moved cord..
LOOP UNTIL INKEY$ = CHR$(27)'End on Esc key
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
(x.t.r.GRAPHICS)