basicdosboxqbasicgw-basic

Im trying to make tetris in Basic , but I have encoutered a problem which i cant seem to solve


' Define the subroutine
SUB MySubroutine
    PRINT "Hello, world!"
END SUB

' Call the subroutine
CALL MySubroutine

I wanted to try and make TetrisTetris in qbasic but I'm trying to figure out subs in QBasic and for some reason, there's an error that states "statements cannot be placed between subs/functions" (on line 6 for the code above). I have clearly ended the sub as seen in line 4 . how can I fix this, I have tried many different versions of qbasic and different compilers for qbasic and still I get the same issue yes I tried reinstalling qbasic

If you wonder why im using basic in the first place its because i saw a movie where a guy made tetris in qbasic ( he dint have a video card and used [] insted of graphics )


Solution

  • In QBasic you edit your SUB's and FUNCTION's each in their separate windows. In such an edit window, the END SUB or END FUNCTION statement is supposed to be the last statement. Nothing should follow it.

    ' Define the subroutine
    SUB MySubroutine
        PRINT "Hello, world!"
    END SUB
    

    From such an edit window, you need to return to the main module (using F2 and selecting the program's name pressing Enter) and place your CALL MySubroutine statement there, along with all the rest that isn't either a SUB or a FUNCTION.