POV-Ray : Newsgroups : povray.general : End of data File Server Time
3 Aug 2024 06:15:00 EDT (-0400)
  End of data File (Message 1 to 2 of 2)  
From: Charm Quark
Subject: End of data File
Date: 30 Apr 2004 15:25:00
Message: <web.4092a796964deb46934b17180@news.povray.org>
I am attempting to have povray read in a data file of format 2279
lines, with 8 columns. The file is comma and tab delimited. That is, each
item is followed by a comma, and then a tab.
     For some reason, povray is not detecting the end of the file, and is
going on to attempt to read in data past the end of the file, upon which it
then crashes, quitting. I don't know if this is a bug in the program, or if
I'm doing something wrong. Has anyone else encountered this, or do any of
you know what's going on?
     I post below the offending code.

#fopen dataFile "3_Center_RA_Dec_cz_Shell_80th_POV.txt" read
#fopen debugFile "debug.txt" write

#declare LinesInFile = 2279;
#declare pointsData = array[3][LinesInFile]

#declare i = 0;
#while ( defined(dataFile) )

 #declare x1 = 0.0;
 #declare x2 = 0.0;
 #declare x3 = 0.0;
 #declare RA = 0.0;
 #declare Dec = 0.0;
 #declare cz = 0.0;
 #declare r = 0.0;
 #declare mag = 0.0;

 #read( dataFile, x1,x2,x3,RA,Dec,cz,r,mag)

 #declare i = i + 1;

#end

#debug concat( "nnTotal values read from file: ", str(i,5,0), "nn" )
#fclose dataFile


Post a reply to this message

From: Alain
Subject: Re: End of data File
Date: 1 May 2004 09:57:15
Message: <4093acbb$1@news.povray.org>
Charm Quark nous apporta ses lumieres ainsi en ce 2004/04/30 15:23... :

>     I am attempting to have povray read in a data file of format 2279
>lines, with 8 columns. The file is comma and tab delimited. That is, each
>item is followed by a comma, and then a tab.
>     For some reason, povray is not detecting the end of the file, and is
>going on to attempt to read in data past the end of the file, upon which it
>then crashes, quitting. I don't know if this is a bug in the program, or if
>I'm doing something wrong. Has anyone else encountered this, or do any of
>you know what's going on?
>     I post below the offending code.
>
>#fopen dataFile "3_Center_RA_Dec_cz_Shell_80th_POV.txt" read
>#fopen debugFile "debug.txt" write
>
>#declare LinesInFile = 2279;
>#declare pointsData = array[3][LinesInFile]
>
>#declare i = 0;
>#while ( defined(dataFile) )
>
> #declare x1 = 0.0;
> #declare x2 = 0.0;
> #declare x3 = 0.0;
> #declare RA = 0.0;
> #declare Dec = 0.0;
> #declare cz = 0.0;
> #declare r = 0.0;
> #declare mag = 0.0;
>
> #read( dataFile, x1,x2,x3,RA,Dec,cz,r,mag)
>
> #declare i = i + 1;
>
>#end
>
>#debug concat( "nnTotal values read from file: ", str(i,5,0), "nn" )
>#fclose dataFile
>
>
>
>  
>
You may change your #while as follow: #while(i<LinesInFile)
Another solution is to add a line containing a "sentinel" value, and 
#undef dataFile once you read that value. To use if you don't know how 
many lines you must read. A good value could be something like 999 for 
RA or Dec. Just make sure that all values are present on the last line. 
(programing 101)

Alain


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.