Page 1 of 1

Syntax Error #2

Posted: Fri Mar 31, 2006 12:13 pm
by flirt85
Hi again. I can't seem to figure out READ statments. In the following
code (about the middle), I get a syntax error on the line "READ city, pop". Any ideas are appreciated!


COLOR 15, 1
CLS
DIM pass AS STRING 'password
DIM ct AS INTEGER 'counter

INPUT "Password: ", pass 'enter password
WHILE UCASE$(pass) <> "GO"
ct = ct + 1
REM aborts programs after 3 tries
IF ct = 3 THEN LOCATE 8, 38: PRINT "GoodBye": END
INPUT "Not a valid password, Re-enter: ", pass
WEND

LOCATE 8, 35
PRINT "Password Accepted"
SLEEP 3

DIM city AS STRING 'city
DIM pop AS LONG 'population
DIM x AS INTEGER 'For loop variable
DIM cityin AS STRING 'selected city
DIM yn AS STRING 'continue y or n choice
DIM pstring AS STRING 'print format string

DATA "Cottonwood",5918"
DATA "Flagstaff",45857
DATA "Camp Verde",6243
DATA "Sedona",7720
DATA "Prescott",26455
DATA "Jerome",403
DATA "xxx",-1

CLS
ct = 0 'reset ct to 0
READ city, pop This is the line where I get the error
WHILE city <> "xxx" 'loops until trailer data
ct = ct + 1
PRINT city
READ city, pop
WEND
pstring = " \ \ Population #####, "
yn = "Y" 'sets yn yo "Y" to enter loop
WHILE UCASE$(yn) = "Y" 'loops while choice (y/n) is Y
LOCATE 8, 3 'locates output at input line
PRINT STRING$(50, " ") 'covers previous output with spaces
LOCATE 8, 3
INPUT "Type City name to see Population ", cityin
LOCATE 10
PRINT STRING$(50, " ") 'covers previous output with spaces
PRINT
RESTORE 'return pointer to beginning of data
COLOR 4, 2
PRINT STRING$(40, " ") 'prints spaces to color output area
FOR x = 1 TO ct 'use a FOR loop with the counter
READ city, pop 'prints with pstring format string
IF city = cityin THEN PRINT USING pstring; city; pop
NEXT x

PRINT STRING$(40, " ") 'prints spaces to cover output area
COLOR 15, 1 'returns color to beginning color
LOCATE 16, 13 'locates at y/n input space
PRINT " " 'covers previous input with space
LOCATE 16

PRINT "Do Another? (Press y or n)"
yn = ""
WHILE yn = ""
yn = INKEY$
WEND
WEND

Posted: Fri Mar 31, 2006 12:32 pm
by Zim
DATA "Cottonwood",5918"
DATA "Flagstaff",45857
DATA "Camp Verde",6243
DATA "Sedona",7720
DATA "Prescott",26455
DATA "Jerome",403
DATA "xxx",-1
That quote mark at the end of the first DATA statement line is gonna REALLY goof you up! Could that be it? I know a problem with DATA will show up as an error in the READ.

Posted: Fri Mar 31, 2006 1:03 pm
by flirt85
Thank you! That solved everything.

Posted: Sat Apr 01, 2006 12:39 am
by Seb McClouth
B.t.w. I suggest you use sumfin else for the password thing. If you want I can you show. It somewhat resembles the visual basic password thingy.

grtz