|
|
Hi,
I've got a text file I want to read from:
"first, second, third"
I want to read the first item ("first") into Var1:
#fopen MyFile "test.txt" read
#read (MyFile, Var1)
#fclose MyFile
When I run this code I get the error"
"test.txt" line 1: Parse Error: Expected 'float, vector,
or string literal', undeclared identifier 'first' found instead
Apparently POV-Ray interprets the first data item as an identifier. Is my
understanding of #read wrong?
TIA
Steven
Post a reply to this message
|
|
|
|
stevenvh <nomail@nomail> wrote:
> Hi,
> I've got a text file I want to read from:
> "first, second, third"
> I want to read the first item ("first") into Var1:
> #fopen MyFile "test.txt" read
> #read (MyFile, Var1)
> #fclose MyFile
> When I run this code I get the error"
> "test.txt" line 1: Parse Error: Expected 'float, vector,
> or string literal', undeclared identifier 'first' found instead
> Apparently POV-Ray interprets the first data item as an identifier. Is my
> understanding of #read wrong?
The #read command can only read literals of the same type as in regular
SDL files. If you want it to read a string literal, you have to put it in
quotes. In other words, your file has to contain this:
"first", "second", "third"
As you noticed from the error message, you could also have identifiers
in the file, but they obviously need to be declared before reading the
file for it to work. (Another less-known fact is that you can actually
have #declares and other #-commands in the file being read, and they will
be interpreted accordingly.)
--
- Warp
Post a reply to this message
|
|