The file u2.bin was written by means of a Delphi program. In that program the file was declared
vector = array [1..3] of double; // Delphi
binFile = file of vector; // Delphi end
A vector x is declared and successively assigned and written 22 times. After the file has been closed, then it is checked by means of
assignFile(fb,'u2.bin'); reset(fb); // Delphi
writeln; writeln('x from the binary file');
while not eof(fb) do begin
read(fb,x);
vectlib.writeVector(' ',' ',x);
end{while};
closeFile(fb); // Delphi end
This works as expected and 22 vectors (`triples') appear.
In Asymptote, and since I am new to its file-handling routines, I first made a text version of the binary file and read it successfully. Then I tried to read the binary file. That failed. The Asymptote code is here:
file bin = input("u2.bin",mode="binary"); // Asymptote
triple [] u = new triple [22];
u = bin;
write(" Array of vector u ",u); // Asymptote end
Asymptote says that the length of the vector u is zero.
I tried to read the file bin 22 times by means of for-loop over i and u[i]=bin; Every one of the 22 u[i] was then written as (0,0,0).
Could anyone guide me out of the impasse?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The file u2.bin was written by means of a Delphi program. In that program
the file was declared
vector = array [1..3] of double; // Delphi
binFile = file of vector; // Delphi end
A vector x is declared and successively assigned and written 22 times.
After the file has been closed, then it is checked by means of
assignFile(fb,'u2.bin'); reset(fb); // Delphi
writeln; writeln('x from the binary file');
while not eof(fb) do begin
read(fb,x);
vectlib.writeVector(' ',' ',x);
end{while};
closeFile(fb); // Delphi end
This works as expected and 22 vectors (`triples') appear.
In Asymptote, and since I am new to its file-handling routines, I first
made a text version of the binary file and read it successfully. Then I
tried to read the binary file. That failed. The Asymptote code is here:
file bin = input("u2.bin",mode="binary"); // Asymptote
triple [] u = new triple [22];
u = bin;
write(" Array of vector u ",u); // Asymptote end
Asymptote says that the length of the vector u is zero.
I tried to read the file bin 22 times by means of for-loop over i and u[i]=bin;
Every one of the 22 u[i] was then written as (0,0,0).
The file u2.bin was written by means of a Delphi program. In that program the file was declared
vector = array [1..3] of double; // Delphi
binFile = file of vector; // Delphi end
A vector x is declared and successively assigned and written 22 times. After the file has been closed, then it is checked by means of
assignFile(fb,'u2.bin'); reset(fb); // Delphi
writeln; writeln('x from the binary file');
while not eof(fb) do begin
read(fb,x);
vectlib.writeVector(' ',' ',x);
end{while};
closeFile(fb); // Delphi end
This works as expected and 22 vectors (`triples') appear.
In Asymptote, and since I am new to its file-handling routines, I first made a text version of the binary file and read it successfully. Then I tried to read the binary file. That failed. The Asymptote code is here:
file bin = input("u2.bin",mode="binary"); // Asymptote
triple [] u = new triple [22];
u = bin;
write(" Array of vector u ",u); // Asymptote end
Asymptote says that the length of the vector u is zero.
I tried to read the file bin 22 times by means of for-loop over i and u[i]=bin; Every one of the 22 u[i] was then written as (0,0,0).
Could anyone guide me out of the impasse?
Try writing and reading a two-dimensional array of reals (
real[][]
)instead of an array of triples.
On Fri, Aug 1, 2014 at 1:55 AM, gustaf gustaf4711@users.sf.net wrote:
Charles,
With
file bin = input("u2.bin",mode="binary");
I tried
real [][][] u = new real[22][22][22]; u=bin;
Result: dereference of null array
real [][][] u ; u=bin;
Result: dereference of null array
real [] u = new real [3*22]; u=bin;
Result: u loads perfectly!
Thank you for putting me onto the tracks!