Previous:The #read Directive Main Index Next:The #default Directive
You may write string, float or vector values to a plain ASCII text file from POV-Ray variables using the #write
directive. The file must first be opened in either write
or append
mode using the #fopen
directive. The syntax for #write
is as follows:
- #write(
FILE_HANDLE_ITEM,
DATA_ITEM[,
DATA_ITEM]...)
Where FILE_HANDLE_IDENTIFIER is the previously opened file. It is followed by one or more DATA_ITEMs separated by commas. The parentheses around the identifier list are required. A DATA_ITEM is any valid string expression, float expression, or vector expression. Float expressions are evaluated and written as signed float literals. If you require format control, you should use the str(VALUE,L,P)
function to convert it to a formatted string. See "String Functions" for details on the str
function. Vector expressions are evaluated into three signed float constants and are written with angle brackets and commas in standard POV-Ray vector notation. String expressions are evaluated and written as specified.
Note that data read by the #read
directive must have comma delimiters between values and quotes around string data but the #write
directive does not automatically output commas or quotes. For example the following #read
directive reads a string, float and vector.
#read (MyFile,MyString,MyFloat,MyVect)
It expects to read something like:
"A quote delimeted string" , -123.45, <1,2,-3>
The POV-Ray code to write this might be:
#declare Val1 = -123.45; #declare Vect1 = <1,2,-3>; #write (MyFile,"\"A quote delimited string\",",Val1,",",Vect1,"\n")
See "String Literals" and "Text Formatting" for details on writing special characters such as quotes, newline, etc.
Previous:The #read Directive Main Index Next:The #default Directive