Syntax error, missing symbol in Basic
嗨,每次我尝试运行以下程序时:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | L=-1 OPEN"tty.usbserial-FTG7QLFS:300,N,8,1,CS0,DS" FOR OUTPUT AS #1 WHILE L J=63 MENU: PRINT PRINT"WAITING FOR KEYSTROKE COMMAND" PRINT"TYPE:" PRINT" C-CLOSE SHUTTER" PRINT" O-OPEN SHUTTER" PRINT" R-RESET CONTROL" PRINT" Q-TERMINATE PROGRAM" START: A$ = INKEY$ IF A$ ="O" THEN PRINT #1,CHR$(J+1); PRINT"SHUTTER OPEN COMMAND SENT" GOSUB TIMEOUT GOTO MENU ELSEIF A$ ="C" THEN PRINT #1,CHR$(J+2); PRINT"SHUTTER CLOSE COMMAND SENT" GOSUB TIMEOUT GOTO MENU ELSEIF A$ ="R" THE PRINT #1,CHR$(J+3); PRINT"CONTROL RESET COMMAND SENT" GOSUB TIMEOUT GOTO MENU ELSEIF A$ ="Q" THEN L = 0 PRINT"PROGRAM TERMINATED" ELSE GOTO START END IF WEND END TIMEOUT: FOR I=1 TO 100:NEXT I CLS 0 RETURN |
我得到下面的错误"语法错误,第6行中缺少符号",但是第6行只有一个print语句,所以我无法找出我缺少的是什么。我在Mac OS X上通过Chipmunk Basic运行这个程序。
谢谢
我猜
1 | OPEN"tty.usbserial-FTG7QLFS:300,N,8,1,CS0,DS" AS#1 |
缺少文件访问模式。也许编译器正在寻找这种没有成功的令牌,并在下一行放弃。
花栗鼠的基本文档说:
1 2 3 | open STRINGEXPR for { input|output|append } as # FNUM -- or -- open STRINGEXPR for random as # FNUM len = VAL |
请参见http://anoved.net/cbasdox/statements.html打开
我不太了解花栗鼠基本语,但在其他基本方言(qbasic,freebasic,visualbasic classic,…)中,您必须说明要打开文件的操作。
FreeBasic示例:
1 2 3 | OPEN SomeFile FOR INPUT AS #1 ' input (read-only) OPEN OtherFile FOR OUTPUT AS #2 ' write (replace existing file) OPEN FooFile FOR BINARY AS #3 ' binary (read + write) |
就像指定"r","r+",…在C-ish语言中使用