Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Arrays and reading them from files.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi Guys,

Im trying to write a routine to load a file into a dynamic byte array.

the code looks something like this

var buf:array of byte;
var fh:file;
var x:integer;
begin
x:=256; {this value is actually random}
resizee(buf,x);
assignfile(fh,1);
blockread(fh,buf,x)
{close file stuff here}
end;

It keeps erroring, sometimes, it crashes my whole system?.

Am i going about it all wrong?

If i declare the array as fixed size instead of dynamic it works fine but I need to be able to resize.

Please Help,
Jamie Fuller
 
If fh is declared as file of byte and you use setlength to set the array's size it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top