Posts: 3
Threads: 1
Joined: Jun 2003
The OPEN file command in my code gives me an bad file error. The file path is fine, the file name is fine. I thought my open statement was correct, but I'm probably wrong. Can someone tell me what I'm doing wrong? (My data file is sequential and has four fields.) Please help!
Code:
DIM atmcount AS SINGLE
DIM Anam(20) AS STRING * 15
DIM Aact(20) AS STRING * 10
DIM Abal(20) AS SINGLE
DIM Apin(20) AS SINGLE
atmcount = 0
OPEN "a:\file.txt" FOR INPUT AS #Atmfile
DO WHILE atmcount < 20 AND NOT EOF(Atmfile)
atmcount = atmcount + 1
INPUT #Atmfile, Anam(atmcount)
INPUT #Atmfile, Aact(atmcount)
INPUT #Atmfile, Apin(atmcount)
INPUT #Atmfile, Abal(atmcount)
LOOP
CLOSE #Atmfile
eware technicians carrying screwdrivers.
Posts: 704
Threads: 0
Joined: Dec 2002
It needs to be at least 1. You can do
Atmfile = FREEFILE
if you want your program to automatically find the next available file number. (And it might be "FREFILE" or some other such thing. I haven't used it in a while.)
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3
Threads: 1
Joined: Jun 2003
So do I DIM it as a string and give it a value (atmfile = 1)?
UPDATE:
Where exactly would I do that? At the top of my program, in my declarations? Or with the OPEN command itself?
eware technicians carrying screwdrivers.
Posts: 704
Threads: 0
Joined: Dec 2002
but just in case, Atmfile should be a numeric variable (INTEGER works real well).
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3
Threads: 1
Joined: Jun 2003
It works, it works! Thanks much!
eware technicians carrying screwdrivers.
Posts: 704
Threads: 0
Joined: Dec 2002
.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 1,845
Threads: 44
Joined: Aug 2002
File handles should always be positive and not equal to zero.
Glenn: always those periods...
Posts: 704
Threads: 0
Joined: Dec 2002
:
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 1,845
Threads: 44
Joined: Aug 2002
Posts: 1,166
Threads: 62
Joined: Apr 2003
A thing I noticed a while ago.... when he posts a period, try looking at the post SUBJECT. It's not just a gag, but a way of doing the old * trick on those hierarchial boards like neozones.
am an asshole. Get used to it.