A file bin is opened in native machine binary format. It consists of repetitions of equal-length records. Logically they represent a label of integers and a label-values-dependent bunch of (real) data-records.
A while-loop iterates over the label+data records. This works perfectly until the end of the file is reached: then an error occurs. The reason is that the condition in the while loop does not work; eof(f) is false although all data has been read. That conclusion is based on the successful that precedes. Asymptote says:
The value of eof(bin) has been output and it is false all the time (as well as error(bin)). The Asymptote script is a translation of a Delphi program that reads the same file and it writes the same values for the label-record data.
Any suggestion of how to get out of this?
HereistheAsymptotecodefollowedbytheoutput.
inti; // counterintNp; // number of point,normal pairs in one tristripintNs; // number of tri-strips in this runint [] i6=newint [6]; // Asymptote(int )=Delphi(LongInt)filebin=input("../dat/tri.bin",mode="binary");bin.singlereal(); // OpenGL(GLFloat) = Asymptote(singlereal)//iterate: controlrecordi6, dataxij6i=0;write("run Nps Ns");while(!eof(bin)){ //DOBEGINi=i+1;i6=bin.dimension(6); Np=i6[0]; Ns=i6[2]; // read the "header" of 6 LongIntreal[][][] xij6=newreal[Ns][Np][6];xij6=bin.dimension(Ns,Np,6); // read the datawrite(i,i6[0],i6[2]-6); // log the "header"
} //ENDWHILErunNpsNs130265230983301024308530926308730918308930911030811309112308eof.asy: 15.28: readingarrayoflength0without-of-boundsindex0
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A file bin is opened in native machine binary format. It consists of repetitions of equal-length records. Logically they represent a label of integers and a label-values-dependent bunch of (real) data-records.
A while-loop iterates over the label+data records. This works perfectly until the end of the file is reached: then an error occurs. The reason is that the condition in the while loop does not work; eof(f) is false although all data has been read. That conclusion is based on the successful that precedes. Asymptote says:
The value of eof(bin) has been output and it is false all the time (as well as error(bin)). The Asymptote script is a translation of a Delphi program that reads the same file and it writes the same values for the label-record data.
Any suggestion of how to get out of this?