Blockread
From: Wade Moore (wadepm_at_sbcglobal.net)
Date: 12/31/03
- Next message: Ignacio Vazquez: "Re: Blockread"
- Previous message: Martin James: "Re: critical section failing"
- Next in thread: Ignacio Vazquez: "Re: Blockread"
- Reply: Ignacio Vazquez: "Re: Blockread"
- Reply: Mike Williams (TeamB): "Re: Blockread"
- Reply: Dave White: "Re: Blockread"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Dec 2003 20:49:15 -0600
I am using blockread to get some data from a file. I have set up a
tempoarary record type to get the data and then I write it to the arrays
where the data is stored to be used by the program. The following bit of
code does NOT work. After the first blockread the length of "vals" is set
back to zero!
type
feqdata = record
time:real;
vals:array of single;
end;
var
tdata:feqdata;
time:array of real;
begin
AssignFile(tsdfile,tsdfilename);
reset(tsdfile,sizeof(tdata));
setlength(time,numrecords);
setlength(tdata.vals,totalpoints);
for i:=1 to numrecords do begin
blockread(tsdfile,tdata,1);
time[i]:=tdata.time*24;
for j:=1 to totalpoints do
plotpoint[j].flw[i]:=tdata.vals[i];
end;
However, the code below DOES work. If I change to a fixed length array for
"vals" then everything works fine. The problem is in the real program I
never know a priori what the length of "vals" will be. It appears I can not
have a variable length array if I am using that record to do a blockread?
Thanks for your help guys.
type
feqdata = record
time:real;
vals:array[1..1240] of single;
end;
var
tdata:feqdata;
time:array of real;
begin
AssignFile(tsdfile,tsdfilename);
reset(tsdfile,sizeof(tdata));
setlength(time,numrecords);
for i:=1 to numrecords do begin
blockread(tsdfile,tdata,1);
time[i]:=tdata.time*24;
for j:=1 to 1240 do
plotpoint[j].flw[i]:=tdata.vals[i];
end;
- Next message: Ignacio Vazquez: "Re: Blockread"
- Previous message: Martin James: "Re: critical section failing"
- Next in thread: Ignacio Vazquez: "Re: Blockread"
- Reply: Ignacio Vazquez: "Re: Blockread"
- Reply: Mike Williams (TeamB): "Re: Blockread"
- Reply: Dave White: "Re: Blockread"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|