POV-Ray : Newsgroups : povray.general : File I/O : Re: File I/O Server Time
6 Oct 2024 08:47:21 EDT (-0400)
  Re: File I/O  
From: Thomas de Groot
Date: 18 Apr 2014 03:17:41
Message: <5350d195$1@news.povray.org>
On 18-4-2014 0:05, pbrants wrote:
> Le_Forgeron <jgr### [at] freefr> wrote:
>> Le 17/04/2014 17:17, pbrants nous fit lire :
>>> Here I am again!
>>>
>>> #fopen MyFile "niks.txt" write
>>>    #declare i=1;
>>>    #while (i <= 5)
>>>       #write (MyFile, i,",")
>>>       #declare i=i+1;
>>>       #end  // while
>>>    #fclose Myfile
>>>

>>>
>>> This piece of code gives a parse error on the indicated line:
>>> Cannot read from file niks.txt because the file is open for writing only
>>>
>>> What is wrong here?
>>> I'm using Windows 7
>>
>>
>> You closed Myfile, but opened MyFile. Typo! (Camel vs Pascal)
>
> Sorry, it was a typo indeed, but it gives the same error with the typo
> corrected!

IF I read your code above, you corrected the typo in the #read but not 
in the #write section...

As a side note, be aware that in your #read section, you use the 
parameter i for two different things at the same time. Except if 
intended, you may get strange results. An alternative would be:

#fopen MyFile "niks.txt" read    // Here parse error!
#while (defined (MyFile))
   #read (MyFile, i)
   do here what you want to do with i
#end  // while
#fclose MyFile


Thomas


Post a reply to this message

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