Показать сообщение отдельно
  #6  
Старый 16.12.2011, 17:19
AlexSku AlexSku вне форума
Специалист
 
Регистрация: 07.05.2007
Адрес: Москва
Сообщения: 884
Репутация: 21699
По умолчанию

Почему вы считываете символы, а не числа? Можно вот так:
Код:
type
  TCity = record
    x, y : Integer;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    StringGrid1: TStringGrid;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    c: array[1..10] of TCity;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  F: TextFile;
  I, J: Integer;
begin
  if not OpenDialog1.Execute then Exit;

  AssignFile(F, OpenDialog1.FileName);
  Reset(F);
  ReadLn(F);    // пропускаем первую строку
  for I:= 1 to 5 do
  begin
    Read(F, J, c[J].x, c[J].y);    // считываем числа
    // просмотр
    StringGrid1.Cells[1,J]:= IntToStr(c[J].x);
    StringGrid1.Cells[2,J]:= IntToStr(c[J].y);
  end;
  CloseFile(F);
end;
Ответить с цитированием