December 11, 2024, 09:42:30 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Strange READ results from TXT file

Started by plurald, September 28, 2009, 03:59:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plurald

There must be something obvious I am missing regarding trying to read numbers from a text file into an INT variable named myVar.  Here is an example of the data in the file:
2,2,1,1,3,3,0,0,0

There are nine numbers in this first data line separated by comma's.
Here is the code to read this data:
while EOF(myFile) = 0
   IF(READ(myFile,myVar) = 0)
      PRINT STR$(myVar)
   ENDIF
endwhile

What gets displayed in the console screen from the PRINT statement are not the above single-digit numbers.  Instead, for each number read it shows  9 digits followed by .00     For example, the first number in my file display's as  7414856818.00   

Any ideas what I'm doing wrong?

Thanks.

LarryMc

how did you declare myFile and myVar ?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

plurald

Thanks for the hint.  I had copied the file definition from another program that used a file as a BFILE.   I changed it to FILE and now all is well.   Thanks.