|
|
Warp <war### [at] tagpovrayorg> wrote:
> Charles C <nomail@nomail> wrote:
> > In my original reply I went with the assumption that knowing the amount of
> > data he'd want to display was something he could do manually. But the docs
> > for the "#read" keyword reveal kindof a nifty way to do it. Just add a(n
> > initialized) counter where the "..." is below, and then re-open the file
> > and count/read to that value.
>
> The problem is not reading the data until it ends. The problem is
> how to create an array which can be used to store those values.
I thought I answered that.... Here's an automatically created exact-fit
array for 1D (pending mistakes as always). Hopefully if more than 1D is
needed, the data would be cleanly & predictably divisable quantities of
CSV's, but if not, I guess it's up to Eric to know how the CSV's are
formatted and what assumptions can be made.
#local LengthOfList = 0;
#fopen MyFile "mydata.txt" read
#while (defined(MyFile))
#read (MyFile,Var1,Var2,Var3)
#local LengthOfList = LengthOfList + 1;
#end
//The file is now closed and undefined but we know how long it is.
#declare MyArray = array[LengthOfList];
#fopen MyFile "mydata.txt" read
#local Ctr = 0;
#while (Ctr < LengthOfList)
#read (MyFile, MyArray[Ctr])
#local Ctr = Ctr + 1;
#end
Charles
Post a reply to this message
|
|