您每次尝试运行以下程序时都好:
L=-1
OPEN "tty.usbserial-FTG7QLFS:300,N,8,1,CS0,DS" FOR OUTPUT AS #1
WHILE L
J=63
MENU: PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "WAITING FOR KEYSTROKE COMMAND"
PRINT "TYPE:"
PRINT " C-CLOSE SHUTTER"
PRINT " O-OPEN SHUTTER"
PRINT " R-RESET CONTROL"
PRINT " Q-TERMINATE PROGRAM"
PRINT
PRINT
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行只有一个打印语句,所以我无法弄清楚我错过了什么。我在Mac OS X上通过Chipmunk Basic运行程序。
由于
答案 0 :(得分:1)
我想
OPEN "tty.usbserial-FTG7QLFS:300,N,8,1,CS0,DS" AS#1
缺少文件访问模式。也许编译器正在寻找这样的令牌而没有成功,并且放弃了下一行。
Chipmunk BASIC文档说:
open STRINGEXPR for { input|output|append } as # FNUM
-- or --
open STRINGEXPR for random as # FNUM len = VAL
请参阅http://anoved.net/cbasdox/statements.html#open
我不太了解Chipmunk BASIC,但在其他BASIC方言(QBasic,FreeBASIC,VisualBASIC Classic,...)中,您必须声明要打开文件的操作。
示例FreeBASIC:
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)
就像在C-ish语言中使用fopen
时指定“r”,“r +”,...