QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The ON STRIG(n) statement is an event procedure that directs program flow upon the press of a specified joystick button.

Syntax

ON STRIG(buttonFunction) GOSUB {lineNumber lineLabel}
ON STRIG(buttonFunction[, joystickNumber]) {GOSUB {lineNumber lineLabel} SUBprocedure}

QBasic

Example(s)

Reading a STRIG event to do something in a GOSUB procedure.


ON STRIG(0) GOSUB 10
STRIG(0)ON

DO
    PRINT ".";
    _LIMIT 30
LOOP UNTIL INKEY$ <> ""
END

10
a$ = "[STRIG 0 EVENT]"
FOR x = 1 TO LEN(a$)
    PRINT MID$(a$, x, 1);
    _DELAY 0.02
NEXT
RETURN 

Displays any number of game pad or joystick device button presses.


FOR j = 1 TO 256
    FOR b = 1 TO 256
        ON STRIG((b - 1) * 4, j) JoyButton (j - 1) * 256 + b - 1
    NEXT
NEXT
STRIG ON

DO
    PRINT ".";
    _LIMIT 30
LOOP UNTIL INKEY$ <> ""
END

SUB JoyButton (js AS LONG)
PRINT "Joystick #"; js \ 256 + 1; "button #"; (js AND 255) + 1; "pressed!"
END SUB 

Explanation: Up to 256 controllers can be used in QB64 with many buttons to read.

See Also