首页 > 解决方案 > 为什么这个 GOTO 在 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

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

标签: gotobasicqbasic

解决方案


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

我搜索了一些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

推荐阅读