arrays

Please discuss general Delphi programming topics here.

arrays

Postby hidingmonkey » November 5th, 2003, 1:51 pm

i want to read 1 2 3 4 or something of that format, four integers with a space inbetween from a text file. Once read i need to store each integer into an array so that it can be used later. How would i do this as i have tried many different ways and none seem to work. So for example
myArray[1]=1
myArray[2]=2
etc but it ignores the spaces
hidingmonkey
Member
Member
 
Posts: 1
Joined: November 5th, 2003, 1:47 pm

Postby Kambiz » November 5th, 2003, 7:43 pm

Code: Select all
var
  YourArray: array[1..4] of Integer;
  I: Integer;
  F: TextFile;
begin
  AssignFile(F, 'YourFile.foo');
  Reset(F);
  for I := Low(YourArray) to High(YourArray) do
    Read(F, YourArray[I]);
  CloseFile(F);
end;
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 0 guests