gotobasicqbasic

Why does this GOTO not work in BASIC 256?


2 Print "What is your name"
input nameperson$
Print "What is your Dad's name"
input ageperson$
Print "Your Name is ";nameperson$;" ";ageperson$
GOTO 2

Why does this code not work in BASIC 256? I have tried it in QB64 and it worked.


Solution

  • It's been years since last time I programmed in BASIC, but I remembered that there were different flavors of the language (it was the same with C, Pascal, and others).

    I googled a bit of both QB64 and Basic 256: The short answer is that the BASIC flavor of QB64 supported line numbers, but Basic 256 implemented a newer flavor of BASIC that didn't support line numbers.

    In order to use GOTO in BASIC 256, you must use labels (any identifier followed by a colon ":")

    thisIsALabel: Print "What is your name" 
    input nameperson$ 
    Print "What is your Dad's name" 
    input ageperson$ 
    Print "Your Name is ";nameperson$;" ";ageperson$ 
    GOTO thisIsALabel