Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File error loading into parallel arrays...
#1
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.
Reply
#2
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.
Reply
#3
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.
Reply
#4
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.
Reply
#5
It works, it works! Thanks much!
eware technicians carrying screwdrivers.
Reply
#6
.
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.
Reply
#7
File handles should always be positive and not equal to zero.

Glenn: always those periods... Wink
Reply
#8
:
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.
Reply
#9
er... lol 8)


@
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)