POV-Ray : Newsgroups : povray.general : Problem with file #read  : Re: Problem with file #read Server Time
30 Jul 2024 02:24:31 EDT (-0400)
  Re: Problem with file #read  
From: Adam
Date: 27 Jan 2010 14:33:32
Message: <4b60950b@news.povray.org>
bart wrote:

>  >I can't seem to #read using close to the example in
>  >the Documentation. The example below errors that var2
>  >is an undeclared identifier.
> 
> The reason is that the MyFile (I mean your file) is still open.
>    Just use #fclose MyFile
> instead of #fclose Myfile

No, I don't understand.  See below that Myfile 
is opened and closed for the #write.  And that 
Infile is opened and closed for the #read. 

// if first time through, then write file 
#if (clock = 0)
 #declare xf1 = 4.30 ;
 #declare xf2 = 5.30 ;
 #declare xf3 = 6.30 ;
 #declare xf4 = 7.30 ;
 #declare xf5 = 8.30 ;
 #declare xf6 = 9.30 ;
#fopen MyFile "shapesA.txt" write
#write(MyFile,"\"ShapesA\",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")
#fclose Myfile
#end

#declare var1 = 1.1 ;

// read from file 
#fopen Infile "shapesA.txt" read
#read (Infile, Txt1, var1, var2, var3, var4, var5)
#fclose Infile       
#debug concat("\n\nClock = ",str(clock,1,2)," \n")
#debug concat("File read -> ", str(var2,1,1), " \n")


Post a reply to this message

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