POV-Ray : Newsgroups : povray.advanced-users : File I/O question : Re: File I/O question Server Time
2 Nov 2024 07:25:38 EDT (-0400)
  Re: File I/O question  
From: Margus Ramst
Date: 10 Mar 2000 19:32:32
Message: <38C99491.45FB4438@peak.edu.ee>
Random reading is not very easy with POV. You have to move through records one
by one, i.e. to get to record N you have go through 1,2,3,...,N #reads. For
example get 10th record do sth. like this (untested):

#fopen F "file" read
#local N=10; //Needed record
#local C=0;
//Jump through the first 9 records
#while (C<N)
  #read(F,X)
#end
#read(F,NeededValue)

Of course if all jumps are are known to be forward (i.e. the next record is
always somewhere after the current one) you don't have to start from the
beginning every time (to restart from the beginning you have to close the file
and reopen it)
Not very elegant; if memory is not a critical issue, I suggest you read all
values into an array, and use this instead.
Also note that values _have_ to be separated by commas.

Margus

David Vincent-Jones wrote:
> 
> I would like to be able to selectively read from a text file with records
> terminated with a line feed.
> 
> The #read - #write looks just fine for a single item file but how can I
> select a specific record?


Post a reply to this message

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