[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2006-02-03T11:08:33-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/1325 2006-02-03T11:08:33-05:00 2006-02-03T11:08:33-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10723#p10723 <![CDATA[help on limiting keys]]> Statistics: Posted by Zim — Fri Feb 03, 2006 11:08 am


]]>
2006-02-02T21:25:24-05:00 2006-02-02T21:25:24-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10715#p10715 <![CDATA[help on limiting keys]]>
Right!

But you have to be absolutely sure that (at least) ONE of the cases is true, else the program will bomb. I usually do something like this:

Code:

Input "Option (1) or (2) ", kSelect Case k   case 1 : print "You said ONE"   case 2 : print "You said TWO"   case else 'do nothingEnd Select
Adding that one little line with a comment " 'do nothing " prevents the program from an abnormal abort. Very little code; good insurance; lots of bang for the buck.
Good point, Zim. But if the user hits anything other than 1 or 2, he would get absolutely no output response and wonder ???.

I would enhance your code as follows:

Code:

Input "Option (1) or (2) ", kSelect Case k   case 1 : print "You said ONE"   case 2 : print "You said TWO"   case else : print "Error: Invalid Option"End Select 
*****

Statistics: Posted by moneo — Thu Feb 02, 2006 9:25 pm


]]>
2006-02-02T12:35:28-05:00 2006-02-02T12:35:28-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10704#p10704 <![CDATA[help on limiting keys]]>
But you have to be absolutely sure that (at least) ONE of the cases is true, else the program will bomb. I usually do something like this:

Code:

Input "Option (1) or (2) ", kSelect Case k   case 1 : print "You said ONE"   case 2 : print "You said TWO"   case else 'do nothingEnd Select
Adding that one little line with a comment " 'do nothing " prevents the program from an abnormal abort. Very little code; good insurance; lots of bang for the buck.

Statistics: Posted by Zim — Thu Feb 02, 2006 12:35 pm


]]>
2006-02-01T23:52:41-05:00 2006-02-01T23:52:41-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10699#p10699 <![CDATA[help on limiting keys]]> If I limited the cases possible before SELECT CASE then I don't need CASE ELSE, right?

Statistics: Posted by paulunknown — Wed Feb 01, 2006 11:52 pm


]]>
2006-02-01T11:25:32-05:00 2006-02-01T11:25:32-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10688#p10688 <![CDATA[help on limiting keys]]> Statistics: Posted by Zim — Wed Feb 01, 2006 11:25 am


]]>
2006-01-30T21:27:01-05:00 2006-01-30T21:27:01-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10671#p10671 <![CDATA[help on limiting keys]]> then you will end up doing this.

Code:

SELECT CASE Cheese$ CASE IS "A"   ... CASE IS "B"  ... CASE IS "C"  PRINT "TRY AGAIN" CASE IS "D"  PRINT "TRY AGAIN" CASE IS "E"  PRINT "TRY AGAIN" CASE IS "F"  PRINT "TRY AGAIN"... CASE IS "Z"  PRINT "TRY AGAIN"
You get what I mean, right? Typing out all of the letters? Yeah, thats right... but instead you can do this:

Code:

SELECT CASE Cheese$ CASE IS "A"  PRINT "YOU WIN!" CASE IS "B"  PRINT "YOU WIN!" CASE ELSE  PRINT "YOU FAIL!"
Yeah, you get it now? But if you command your CASEs to use subs/functions/GOTOs, then it will exit without doing anything which can REALLY screw your game/program/OS up...

*caugh* No, I didn't say just like in windows... *caugh*

I hope you got that...

Statistics: Posted by {Nathan} — Mon Jan 30, 2006 9:27 pm


]]>
2006-01-29T15:24:16-05:00 2006-01-29T15:24:16-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10655#p10655 <![CDATA[help on limiting keys]]>
Just remember, if you're going to use SELECT CASE after a keyboard input, you'd better have a CASE ELSE at the end of your case list, or you'll have to have a CASE for every key on the keyboard! Otherwise, after the first keystroke you're not checking for, the program bombs.
Sorry but I don't know what you are saying.

Statistics: Posted by paulunknown — Sun Jan 29, 2006 3:24 pm


]]>
2006-01-27T22:45:48-05:00 2006-01-27T22:45:48-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10649#p10649 <![CDATA[help on limiting keys]]>
(PaulUnknown's "nevermine" notwithstanding...)

Just remember, if you're going to use SELECT CASE after a keyboard input, you'd better have a CASE ELSE at the end of your case list, or you'll have to have a CASE for every key on the keyboard! Otherwise, after the first keystroke you're not checking for, the program bombs.
Very sound advice, Zim. Hope it doesn't fall on deaf ears. What'd you say? :shock:

Statistics: Posted by moneo — Fri Jan 27, 2006 10:45 pm


]]>
2006-01-27T12:52:53-05:00 2006-01-27T12:52:53-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10639#p10639 <![CDATA[help on limiting keys]]>
Just remember, if you're going to use SELECT CASE after a keyboard input, you'd better have a CASE ELSE at the end of your case list, or you'll have to have a CASE for every key on the keyboard! Otherwise, after the first keystroke you're not checking for, the program bombs.

Statistics: Posted by Zim — Fri Jan 27, 2006 12:52 pm


]]>
2006-01-27T07:01:51-05:00 2006-01-27T07:01:51-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10638#p10638 <![CDATA[help on limiting keys]]>

Code:

DOk$ = INKEY$LOOP UNTIL k$ = "w"SELECT CASE k$[...]
You bonehead...that specific code is never gonna work. :D k$ is ALWAYS going to be w after the loop because the loop won't end until it is so your SELECT CASE will only ever work with CASE "w". :P Silly Swede... ;)
Yes, just like all previous code snippets..

Statistics: Posted by Z!re — Fri Jan 27, 2006 7:01 am


]]>
2006-01-27T01:27:02-05:00 2006-01-27T01:27:02-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10637#p10637 <![CDATA[help on limiting keys]]> Statistics: Posted by paulunknown — Fri Jan 27, 2006 1:27 am


]]>
2006-01-27T01:02:06-05:00 2006-01-27T01:02:06-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10636#p10636 <![CDATA[help on limiting keys]]> So what does work?

Statistics: Posted by paulunknown — Fri Jan 27, 2006 1:02 am


]]>
2006-01-24T15:12:47-05:00 2006-01-24T15:12:47-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10621#p10621 <![CDATA[help on limiting keys]]>

Code:

Key$ = ""WHILE Key$ = ""Key$ = INKEY$WENDSELECT CASE LCASE$(Key$)   'LCASE$ is optionalCASE "w"[. . .]CASE "e"[. . .]END SELECT
Or, to test for other keys, you can use ASCII, as shown.

Code:

SELECT CASE ASC(LCASE$(Key$))CASE 27[. . .] 'ESC was pressed.END SELECT
They *should* work, but are untested.

Statistics: Posted by Patz QuickBASIC Creations — Tue Jan 24, 2006 3:12 pm


]]>
2006-01-25T12:49:24-05:00 2006-01-24T12:28:24-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10616#p10616 <![CDATA[Sorry...]]>
EDIT: Yup, that's better...

Statistics: Posted by Zim — Tue Jan 24, 2006 12:28 pm


]]>
2006-01-24T14:57:53-05:00 2006-01-23T13:16:41-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=10603#p10603 <![CDATA[help on limiting keys]]>

Code:

DO    SELECT CASE INKEY$         CASE "a"              'do whatever               EXIT DO         CASE "b"              'do whatever               EXIT DO     END SELECTLOOP

Statistics: Posted by The Awakened — Mon Jan 23, 2006 1:16 pm


]]>