|
|
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
|
|