为什么这个 GOTO 在 BASIC 256 中不起作用?

1 basic goto qbasic

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
Run Code Online (Sandbox Code Playgroud)

为什么这段代码在 BASIC 256 中不起作用?我已经在QB64中尝试过并且有效。

Roi*_*mer 5

距离我上次使用 BASIC 编程已经有很多年了,但我记得该语言有不同的风格(C、Pascal 和其他语言也是如此)。

我在 google 上搜索了一些QB64Basic 256:简短的答案是QB64的 BASIC 风格支持行号,但Basic 256实现了一种不支持行号的较新风格的 BASIC。

为了GOTOBASIC 256中使用,您必须使用标签(任何标识符后跟冒号“:”)

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
Run Code Online (Sandbox Code Playgroud)

  • 很可能(但不确定)只需在行号后添加冒号即可纠正原始问题,例如“2:打印“你叫什么名字”” (3认同)
  • “距离我上次使用 BASIC 编程已经很多年了,但我记得该语言有不同的风格”……不同的风格只是一种委婉说法。存在混乱的多样性,以至于“BASIC”和“BASIC”现在只是偶然匹配。 (2认同)