POV-Ray : Newsgroups : povray.general : #read file directive... problem? Server Time
18 Nov 2024 01:21:34 EST (-0500)
  #read file directive... problem? (Message 1 to 6 of 6)  
From: Marc Champagne
Subject: #read file directive... problem?
Date: 17 Nov 2002 23:03:30
Message: <Xns92C9EA8D6BC1APOVMIKA@204.213.191.226>
Hi Folks,

I've been trying to read in a text file and can
make no sense of the end results


Create a file named text.txt and put the following into it

-------------BEGIN-----------
"line1"
"line2"
"line3"
"line4"
"line5"
"line6"
-------------END-----------

and then run this code within a scene file (.pov)

-------------BEGIN-----------
#debug "\n--------------------\n"
#declare Lines=0;
#fopen Io "text.txt" read
  #while ( defined(Io) )
    #read (Io,Pat)
    #if ( defined(Io) )
      #debug Pat
      #debug "\n"
      #declare Lines=Lines+1;
    #end
  #end
#fclose

#debug str(Lines,0,0)
#debug " Lines read"
#debug "\n--------------------\n"
-------------END-----------


My results of running above code gives

-------------BEGIN-----------
line1
line3
line5
3 Lines read
-------------END-----------

The results are the same for line termination being LF's or CR/LF's

Baffled

-- 
(MIKA) Marc Champagne
marcch.AT.videotron.DOT.ca
Montreal, CANADA


Post a reply to this message

From: Marc Champagne
Subject: Re: #read file directive... problem?
Date: 17 Nov 2002 23:13:41
Message: <Xns92C9EC47435B7POVMIKA@204.213.191.226>
Marc Champagne <marcch.AT.videotron.DOT.ca> wrote in 
news:Xns### [at] 204213191226:

I found my answer (big loop-hole in docs) very very unclear

Data must have commas even at end of lines as CR/LF, LF, spaces, tabs, 
basicaly any white space are most problably ignored (unless within quotes 
of course...I hope)

Data works when like this

-------------BEGIN-----------
"line1",
"line2",
"line3",
"line4",
"line5",
"line6"
-------------END-----------

Thanks anyways


> 
> I've been trying to read in a text file and can
> make no sense of the end results
> 
> 
> Create a file named text.txt and put the following into it
> 
> -------------BEGIN-----------
> "line1"
> "line2"
> "line3"
> "line4"
> "line5"
> "line6"
> -------------END-----------



-- 
(MIKA) Marc Champagne
marcch.AT.videotron.DOT.ca
Montreal, CANADA


Post a reply to this message

From: hughes, b 
Subject: Re: #read file directive... problem?
Date: 17 Nov 2002 23:17:21
Message: <3dd869d1@news.povray.org>
"Marc Champagne" <marcch.AT.videotron.DOT.ca> wrote in message
news:Xns### [at] 204213191226...
>
> -------------BEGIN-----------
> "line1"
> "line2"
> "line3"
> "line4"
> "line5"
> "line6"
> -------------END-----------
>
> My results of running above code gives
>
> -------------BEGIN-----------
> line1
> line3
> line5
> 3 Lines read
> -------------END-----------

Yes, you used it incorrectly. I don't know the real reason why it gathers
every other line but your answer is to add a comma to the end of each line.
--
Farewell,
Bob


Post a reply to this message

From: Peter Popov
Subject: Re: #read file directive... problem?
Date: 18 Nov 2002 05:59:25
Message: <rthhtuc21ujio2ls4ilhtbohqu1enisd7v@4ax.com>
On 17 Nov 2002 23:13:41 -0500, Marc Champagne <nos### [at] pleasecom>
wrote:

>I found my answer (big loop-hole in docs) very very unclear

>Data must have commas even at end of lines as CR/LF, LF, spaces, tabs, 
>basicaly any white space are most problably ignored (unless within quotes 
>of course...I hope)

What's unclear about this sentence? Does it mention line-by-line
reading or anything?

"The format of the data to be read must be a series of valid string
literals, float literals, or vector literals separated by commas."


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Marc Champagne
Subject: Re: #read file directive... problem?
Date: 23 Nov 2002 21:05:14
Message: <Xns92CFD67F66EBCPOVMIKA@204.213.191.226>
Peter Popov <pet### [at] vipbg> wrote in
news:rthhtuc21ujio2ls4ilhtbohqu1enisd7v@4ax.com: 

> What's unclear about this sentence? Does it mention line-by-line
> reading or anything?
> 
> "The format of the data to be read must be a series of valid string
> literals, float literals, or vector literals separated by commas."

I agree Peter, there is no mention of "lines", but there is also no
mention that white space between fields are ignored. 

It's not common in the "Windows way" of handling files (and am by no
means trying to justify it either). 

Being a Xenix/Unix buff for (wow, shesh, i'm getting old) 18+ years now,
I have no problems in dealing with file structures, I have seen many
horrors (especially from the Microsoft generation). 

I still don't like the 1 liner above to describe a file structure.

I managed to figure it out myself, as I do many times a week at work,
but for the average joe, he/she will most likely make the same
unconscious mistake I did.....defacto-windows-way-text-file. 

Much obliged
-- 
(MIKA) Marc Champagne
marcch.AT.videotron.DOT.ca
Montreal, CANADA


Post a reply to this message

From: ingo
Subject: Re: #read file directive... problem?
Date: 24 Nov 2002 03:58:40
Message: <Xns92D06662C516Dseed7@povray.org>
in news:Xns### [at] 204213191226 Marc Champagne wrote:

>> "The format of the data to be read must be a series of valid string
>> literals, float literals, or vector literals separated by commas."
> 
> I still don't like the 1 liner above to describe a file structure.
> 

Is there somebody, able and willing, to write a better documentation 
section for the #read directive? Please post it to the 
povray.documentation.inbuilt group (as plain text).

Thanks,

Ingo


Post a reply to this message

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