user2437006
user2437006

Reputation: 11

Syntax error, missing symbol in Basic

Hi every time I try to run the following program:

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

I get the following error "syntax error, missing symbol in line 6", but at line 6 there is only a print statement so I can't figure out what I'm missing. I'm running the program through Chipmunk Basic on Mac OS X.

Thanks

Upvotes: 1

Views: 905

Answers (1)

MrSnrub
MrSnrub

Reputation: 1183

I guess

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

is missing a file access mode. Maybe the compiler is looking for such tokens without success and gives up in the next lines.

The Chipmunk BASIC docs say:

open STRINGEXPR for { input|output|append } as # FNUM
-- or --
open STRINGEXPR for random as # FNUM len = VAL

See http://anoved.net/cbasdox/statements.html#open

I don't really know Chipmunk BASIC but also in other BASIC dialects (QBasic, FreeBASIC, VisualBASIC Classic, ...) you have to state for what actions you want to open your file.

Examples 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)

It's like specifying "r", "r+", ... when using fopen in C-ish languages.

Upvotes: 1

Related Questions