|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |