POV-Ray : Newsgroups : povray.general : How does povray read a file? : Re: How does povray read a file? Server Time
5 Aug 2024 06:13:03 EDT (-0400)
  Re: How does povray read a file?  
From: hughes, b 
Date: 13 Nov 2002 15:15:52
Message: <3dd2b2f8@news.povray.org>
"Greg M. Johnson" <gregj:-)565### [at] aolcom> wrote in message
news:3dd2a565$3@news.povray.org...
>
> Can you show me code that would open this file?

I was just about to post a reply when I saw you asked this. Here's what I
was going to say:

"Christoph Hormann" <chr### [at] gmxde> wrote in message
news:3DD29A93.A01108E1@gmx.de...
>
> The #read directive can read files with elements separated by commas.
> Therefore your list of names won't be readable unless you add commas
> between the names.


Actually it can be without commas, just isn't correct and it can't see more
than one name during a single read I think. However, each successive reading
will get the odd numbered line name. Anyway, the idea is to create strings:


#declare WriteRead=2;

#switch (WriteRead)
#case (1)

// first part
 #fopen NameList "c:\\namelist.txt"

 append

#declare C=1;

#while (C<10)

 #write (NameList,
  concat(
 "\"name\"", // make it quoted, a string literal
 #if (C<9) // lose last comma
 ",", // comma separations
 #end
 "\n" // separate lines for each writing
 )
 )

#declare C=C+1;

#end

//#fclose NameList

#break
#case (2)

// second part
 #fopen NameList "c:\\namelist.txt"

    read

 #while (defined (NameList)) // loop until finished getting all from file

     #read (NameList, Name)

         #debug concat(Name,"\n") // see it in message stream text

 #end

#break
#end

Another thing I noticed is that if the last name has a comma after it too,
like all other lines, then the reading loop picks up a duplicate. So it
seems wise to keep to the format recommended.

> Christoph Hormann again, also said:
> You can of course process the file into a POV readable form using a script
> invoked by pre_scene_command.

No comment on this from me since I'm not sure what Christoph had in mind.
:-)

Bob H.


Post a reply to this message

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