我该如何解决有关读取数据的QBASIC中的此语法错误

时间:2018-10-23 04:40:54

标签: syntax syntax-error qbasic read-data

这是我的代码

INPUT "what year right now : ", thn1
CLS
thn2 = thn1
num = 0
PRINT "No      Jenis Kelamin     Tanggal Lahir     NPM         Nama"
10 READ jk$, tgl$, thl, npm$, nma$
IF jk$ = "0" THEN END
thn1 = thn2
thn1 = thn1 - thl
IF jk$ = "L" OR thn1 < 18 THEN GOTO 10
num = num + 1
PRINT num, jk$, tgl$, npm$, nma$
GOTO 10
DATA "L","11-03-2000",2000,"52418436","Fajar","P","20-06-1999",1999,"89436754","Rida","P","17-01-2002",2001,"37904638","Selly","L","09-08-1998",1998,"47382901","Fadli","P","28-04-2000",2000,"37464903","Bella","0","0","0","0","0","0"

输出与我想要的一样,但是有弹出警报:

未处理的错误#2

第6行(在主模块中) 语法错误 继续吗?

是的

该如何解决?

1 个答案:

答案 0 :(得分:1)

我的猜测是,当最后一个"0"时,您尝试将STRING(类型thl)读入变量SINGLE(默认类型为READ)中发生(您还需要删除最后一个"0")。更改

"Bella","0","0","0","0","0","0"

"Bella","0","0",0,"0","0"

您还可以使用多个DATA语句来使事情井井有条。假设内存不是问题,这就是我编写代码的方法:

DATA "L","11-03-2000",2000,"52418436","Fajar"
DATA "P","20-06-1999",1999,"89436754","Rida"
DATA "P","17-01-2002",2001,"37904638","Selly"
DATA "L","09-08-1998",1998,"47382901","Fadli"
DATA "P","28-04-2000",2000,"37464903","Bella"
DATA "0","00-00-0000",0000,"00000000","00000"