POV-Ray : Newsgroups : povray.general : How does povray read a file? Server Time
6 Nov 2024 02:21:34 EST (-0500)
  How does povray read a file? (Message 1 to 8 of 8)  
From: Greg M  Johnson
Subject: How does povray read a file?
Date: 13 Nov 2002 13:24:08
Message: <3dd298c8@news.povray.org>
I'm looking for a general understanding of what povray does when it reads  a
file.

I thoroughly understand how to #write a file and how it responds to a file
where I #include   text that is actually SDL.

But I don't know how to handle a file that is not SDL.  Say it is just a
list of names, one per line:

smith
barney
fife
luck
olsen


How can I get this into povray?  Or can povray only #read something that is
SDL?


Post a reply to this message

From: Christoph Hormann
Subject: Re: How does povray read a file?
Date: 13 Nov 2002 13:31:48
Message: <3DD29A93.A01108E1@gmx.de>
"Greg M. Johnson" wrote:
> 
> [...]
> 
> But I don't know how to handle a file that is not SDL.  Say it is just a
> list of names, one per line:
> 
> smith
> barney
> fife
> luck
> olsen
> 
> How can I get this into povray?  Or can povray only #read something that is
> SDL?

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.

You can of course process the file into a POV readable form using a script
invoked by pre_scene_command.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 02 Nov. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Greg M  Johnson
Subject: Re: How does povray read a file?
Date: 13 Nov 2002 14:17:57
Message: <3dd2a565$3@news.povray.org>
Thanks.

Can you show me code that would open this file?




"Christoph Hormann" <chr### [at] gmxde> wrote in message
news:3DD29A93.A01108E1@gmx.de...
>
>
> "Greg M. Johnson" wrote:
> >
> > [...]
> >
> > But I don't know how to handle a file that is not SDL.  Say it is just a
> > list of names, one per line:
> >
> > smith
> > barney
> > fife
> > luck
> > olsen
> >
> > How can I get this into povray?  Or can povray only #read something that
is
> > SDL?
>
> 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.
>
> You can of course process the file into a POV readable form using a script
> invoked by pre_scene_command.
>
> Christoph
>
> --
> POV-Ray tutorials, include files, Sim-POV,
> HCR-Edit and more: http://www.tu-bs.de/~y0013390/
> Last updated 02 Nov. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: hughes, b 
Subject: Re: How does povray read a file?
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

From: Greg M  Johnson
Subject: Re: How does povray read a file?
Date: 13 Nov 2002 16:05:43
Message: <3dd2bea7$1@news.povray.org>
Thanks greatly .  But your example has povray reading something already set
up in SDL. You're adding "\n" 's and so forth.  What if there's no "\n"?
Suppose I have some more sophisticated files which are too big to hand-edit
into SDL-compatible code.
Is povray capable of reading these, and if so could you humor me by showing
an example.

just a generic idea of code that enables it to read "whatever's there."
Then I can do my own "parsing" of the data, perhaps looking for commas and
the like.


Post a reply to this message

From: hughes, b 
Subject: Re: How does povray read a file?
Date: 13 Nov 2002 19:40:55
Message: <3dd2f117@news.povray.org>
"Greg M. Johnson" <gregj:-)565### [at] aolcom> wrote in message
news:3dd2bea7$1@news.povray.org...
> Thanks greatly .  But your example has povray reading something already
set
> up in SDL. You're adding "\n" 's and so forth.  What if there's no "\n"?
> Suppose I have some more sophisticated files which are too big to
hand-edit
> into SDL-compatible code.
> Is povray capable of reading these, and if so could you humor me by
showing
> an example.
>
> just a generic idea of code that enables it to read "whatever's there."
> Then I can do my own "parsing" of the data, perhaps looking for commas and
> the like.

It's an interesting problem. I don't know of a way around the need for
quotes or commas for this kind of thing. Sorry. POV-Ray will always see a
lone word or number or symbol as being the proverbial undeclared identifier.
If it were all put into a single pair of quotation marks then perhaps it
could be dissected into parts of the string but way too difficult I'd think.

The \n for carriage returns or line feeds isn't needed though, I had only
done that to match up with your example for list of names. Commas are
important, needed for separating the data into discrete pieces.
Seems your real need might be to check into using some program that does
CSV, comma separated values. Whatever that may entail I wouldn't know. A
raw, ordinary, word just isn't going to work right anyhow though. Well, from
my experience it can't.


Post a reply to this message

From: Andrew Cocker
Subject: Re: How does povray read a file?
Date: 13 Nov 2002 20:52:19
Message: <3dd301d3$1@news.povray.org>
"hughes, b." <omn### [at] charternet> wrote in message news:3dd2f117@news.povray.org...

> Seems your real need might be to check into using some program that does
> CSV, comma separated values. Whatever that may entail I wouldn't know. A
> raw, ordinary, word just isn't going to work right anyhow though. Well, from
> my experience it can't.

When I used Realflow data in POV, I had to convert very large files (consisting of
variables
separated by just spaces) into comma separated files. The only thing I could find was
a
commercial prog called Text Pipe Pro. By setting up various rules, I could get it to
discard
the first 3 lines, then place commas wherever it found a space.

Gergely Vandor (apparently) used HandyFile Find&Replace to do the same thing. Sorry, I
don't
have a link.

All the best,

Andy Cocker


Post a reply to this message

From: =Bob=
Subject: Re: How does povray read a file?
Date: 14 Nov 2002 20:28:52
Message: <3dd44dd4@news.povray.org>
"hughes, b." <omn### [at] charternet> wrote in message news:3dd2f117@news.povray.org...
[deletions]

: It's an interesting problem. I don't know of a way around the need for
: quotes or commas for this kind of thing. Sorry. POV-Ray will always see a
: lone word or number or symbol as being the proverbial undeclared identifier.
: If it were all put into a single pair of quotation marks then perhaps it
: could be dissected into parts of the string but way too difficult I'd think.


I've been playing around with a Win version of Pov3.5 that
reads dBASE files into arrays of strings. It doesn't use indexes
yet and it's not tested fully.
=Bob=


Post a reply to this message

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