Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Got so drunk for St. Patricks Day, I programmed something in graphics...
#23
Maybe you entered a website name that spawns other sites? If not, maybe you have a sticky F12 key. If that's what happened, it makes a good case for using _KeyHit instead of INKEY$. _KeyHit would allow us to wait until the key was released.

Now I love INKEY$ but it is a bit fickle. I noticed when testing, it would return a null value at times the key was  firmly held down. That ain't right! That makes it impossible to poll for that status change, unless we jimmy around with some tricks like using time loops...

Code: (Select All)
DO
    _LIMIT 60
    b$ = INKEY$
    SELECT CASE LEN(b$)
        CASE 0 ' Time loop to test for key release.
            IF LEN(oldb$) THEN
                IF ABS(z1 - TIMER) > .1 THEN
                    oldb$ = ""
                END IF
            END IF
        CASE 1
            IF b$ = CHR$(27) THEN SYSTEM ELSE PRINT b$;
        CASE 2
            IF oldb$ <> b$ THEN
                SELECT CASE b$
                    CASE CHR$(0) + CHR$(68): BEEP
                    CASE CHR$(0) + CHR$(133): PRINT "F11 "
                    CASE CHR$(0) + CHR$(134): PRINT "F12 "
                END SELECT
                oldb$ = b$
                SLEEP 1 ' Needed to prevent double entry.
            END IF
            z1 = TIMER
    END SELECT
LOOP

So hey guys, do you see the SLEEP 1 statement? For fun, take it out, run it again, and press and hold the F11 key. I always got a double printing of "F11" before it locked that key out without the SLEEP statement present. Same with F12. Adding SLEEP 1 took care of that. Another workaround was to increase the timer from .1 seconds to .5 or more. So why do either of these code modifications make a difference? Well, you might as well ask me what you get when you cross an elephant with a rhino... 

Elephino!  Huh

Pete Big Grin
Reply


Messages In This Thread
RE: Got so drunk for St. Patricks Day, I programmed something in graphics... - by Pete - 03-30-2024, 05:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  SVG graphics demos James D Jarvis 4 901 03-25-2025, 12:41 AM
Last Post: James D Jarvis
  ^^0^^---- What do you graphics guys think? Pete 9 1,841 04-05-2024, 07:26 PM
Last Post: TheBOB
  Oh when will this drunken binge end? Another graphics routine. Pete 3 924 03-31-2024, 08:29 AM
Last Post: Pete
  simple 2D vector graphics part 25 madscijr 0 574 11-18-2022, 04:25 PM
Last Post: madscijr
  simple 2D vector graphics part 19 madscijr 1 671 11-18-2022, 05:12 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)