POV-Ray : Newsgroups : povray.general : Odd effect using #read Server Time
5 Nov 2024 20:16:21 EST (-0500)
  Odd effect using #read (Message 1 to 1 of 1)  
From: Michael Andrews
Subject: Odd effect using #read
Date: 6 Aug 1998 08:08:29
Message: <35C98EE6.E9262348@remove-this.reading.ac.uk>
Hi folks,
    I was looking at the file read/write directives last night and hit a
feature I wasn't expecting; #declares seem to be _parsed_ automatically
if they occur in a file before a readable item.
    Here's a file showing what I mean:-

// begin pov code

#fopen Test "test.txt" write

#declare Text = "#declare A = \"A short string of text.\nAnd another
after new line.\"\n"
#write (Test, Text)

#declare Text = "#declare S = sphere { 10*z, 1 pigment { rgb 0.8 }
finish { ambient 1 } }\n"
#write (Test, Text)

#declare Text = "\"More text.\"\n"
#write (Test, Text)

#fclose Test
#declare Text = ""

#fopen Test "test.txt" read

#read (Test, Text)
#debug concat("Text = ", Text, "\n")

#fclose Test

/* Here come the wierd bits ... */

// 'A' is only #declared in a string that is written
// to file and parsed back in somehow.

#debug concat("A = ", A, "\n")

// 'S' is only #declared in the file as well ...

object { S }

 // end pov code

    Is this feature documented (is it even usefull?) or is it just a
side effect of how the parser works?
    All this stemmed from not reading the documentation first and trying
to write a pov scene that could read an image file to figure out where
to place objects ... now that would be useful, yes?

    Bye for now,
            Mike Andrews.


Post a reply to this message

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