POV-Ray : Newsgroups : povray.general : Problem with file #read Server Time
30 Jul 2024 04:10:35 EDT (-0400)
  Problem with file #read (Message 1 to 9 of 9)  
From: Adam
Subject: Problem with file #read
Date: 27 Jan 2010 02:41:59
Message: <4b5fee46@news.povray.org>
I can't seem to #read using close to the example in 
the Documentation. The example below errors that var2 
is an undeclared identifier. 

I've tried with and without a trailing comma, after 
xf5 and before the closing quote 

Am using version 3.6.1.c.id8.win32 on WinXP. 
Any suggestions much appreciated. 

// 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

From: Thomas de Groot
Subject: Re: Problem with file #read
Date: 27 Jan 2010 03:22:07
Message: <4b5ff7af$1@news.povray.org>
"Adam" <ahc### [at] ihugconz> schreef in bericht 
news:4b5fee46@news.povray.org...
>[...]
> #write(MyFile,"\"ShapesA\",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")
>[...]

I think there is a " missing after ShapesA\" in the line above. It should 
probably be:

#write(MyFile,"\"ShapesA\"",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")

I don't know if this will fix the problem though.

Thomas


Post a reply to this message

From: Adam
Subject: Re: Problem with file #read
Date: 27 Jan 2010 04:05:11
Message: <4b6001c6@news.povray.org>
Thomas de Groot wrote:

> 
> "Adam" <ahc### [at] ihugconz> schreef in bericht
> news:4b5fee46@news.povray.org...
>>[...]
>> #write(MyFile,"\"ShapesA\",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")
>>[...]
> 
> I think there is a " missing after ShapesA\" in the line above. It should
> probably be:
> 
> #write(MyFile,"\"ShapesA\"",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")
> 
> I don't know if this will fix the problem though.
> 
> Thomas

No, as written does make sense. And the file #write works OK 
to disk. After the #write section a file appears containing; 
"ShapesA",4.3,5.3,6.3,7.3,8.3     as expected. 

I remain baffled that the #read doesn't load the string and floats.


Post a reply to this message

From: bart
Subject: Re: Problem with file #read
Date: 27 Jan 2010 14:13:25
Message: <4b609055$1@news.povray.org>
>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


Post a reply to this message

From: Adam
Subject: Re: Problem with file #read
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

From: "Jérôme M. Berger"
Subject: Re: Problem with file #read
Date: 27 Jan 2010 14:37:52
Message: <4b609610$1@news.povray.org>
Adam wrote:
> 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. 
> 
> #fopen MyFile "shapesA.txt" write
> #write(MyFile,"\"ShapesA\",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")
> #fclose Myfile
> #end
> 
	Pov is case-sensitive, therefore MyFile is different from Myfile...

		Jerome
-- 
mailto:jeb### [at] freefr
http://jeberger.free.fr
Jabber: jeb### [at] jabberfr


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

From: bart
Subject: Re: Problem with file #read
Date: 27 Jan 2010 14:48:41
Message: <4b609899@news.povray.org>
>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.

You use "MyFile" to open,
but "Myfile" to close,
POV-Ray identifiers are case sensitive,
and hence file "MyFile" is still open.
Again, if we replace "#fclose Myfile"
with "#fclose MyFile" it works as it should.


Post a reply to this message

From: Adam
Subject: Re: Problem with file #read
Date: 27 Jan 2010 16:02:14
Message: <4b60a9d5@news.povray.org>
bart wrote:

>  >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.
> 
> You use "MyFile" to open,
> but "Myfile" to close,
> POV-Ray identifiers are case sensitive,
> and hence file "MyFile" is still open.
> Again, if we replace "#fclose Myfile"
> with "#fclose MyFile" it works as it should.

Now I understand. Thanks Bart !


Post a reply to this message

From: Adam
Subject: Re: Problem with file #read
Date: 27 Jan 2010 16:03:48
Message: <4b60aa33@news.povray.org>


> Adam wrote:
>> 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.
>> 
>> #fopen MyFile "shapesA.txt" write
>> #write(MyFile,"\"ShapesA\",",xf1,",",xf2,",",xf3,",",xf4,",",xf5"\n")
>> #fclose Myfile
>> #end
>> 
> Pov is case-sensitive, therefore MyFile is different from Myfile...
> 
> Jerome


Well put, Jerome.  I thought either I or Bart was 
crazy for a bit there. Now I can see that I need 
better glasses.   Many thanks.


Post a reply to this message

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