1
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.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Barthdry
  • 7
  • 4

1 Answers1

5

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
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Roimer
  • 1,419
  • 1
  • 19
  • 25
  • 2
    "It's been years since last time I programmed in BASIC, but I remembered that there where differemnt flavors of the language" ...different flavors is quiet an euphemism. There has been a chaotic diversity, to an extend that "BASIC" and "BASIC" now do only match by chance. – Gyro Gearloose Dec 25 '20 at 16:26
  • 3
    It is likely, but not definite, that the original problem could have been corrected by just putting a colon after the line number, e.g., `2: Print "What is your name"` – Jeff Zeitlin Dec 25 '20 at 21:02