1

嗨,每次我尝试运行以下程序时:

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 运行程序。

谢谢

4

1 回答 1

1

我猜

OPEN "tty.usbserial-FTG7QLFS:300,N,8,1,CS0,DS" AS#1

缺少文件访问模式。也许编译器正在寻找这样的标记但没有成功,并在下一行中放弃了。

花栗鼠 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)

就像fopen在 C-ish 语言中使用时指定“r”、“r+”、...一样。

于 2013-06-14T09:04:17.697 回答