Показать сообщение отдельно
  #4  
Старый 18.04.2018, 19:08
Аватар для Alegun
Alegun Alegun вне форума
LMD-DML
 
Регистрация: 12.07.2009
Адрес: Богородское
Сообщения: 3,025
Версия Delphi: D7E
Репутация: 1834
По умолчанию

Цитата:
Сообщение от LIONSMILE
...Помогите пожалуйста с обработчиком Button2...
Вот предварительный вариант, пока наполнение через сетки идёт, будет-ли работать?
Код:
procedure TForm1.Button2Click(Sender: TObject);
var
 s:     string;
 i,j,b: integer;
begin

 for b := 0 to  StringGrid1.RowCount-1 do
  begin
   XMLDocument1.LoadFromFile('https://geocode-maps.yandex.ru/1.x/?geocode=' +
    StringGrid1.Cells[0, b]);

   Application.ProcessMessages;

   XMLDocument1.Active:= true;
   s:= VarToStr(XMLDocument1.DocumentElement.ChildNodes.Nodes['GeoObjectCollection'].XML);

   Application.ProcessMessages;

   j:= Pos('<pos>', s)+5;
   i:= Pos('</pos>',s);
   s:= Copy(s, j, i-j);
   j:= Pos(' ', s);

   with StringGrid2 do
    begin
     RowCount:= b;
     Rows[b][0]:= StringGrid1.Cells[0,b];
     Rows[b][1]:= Copy(s,1,j-1);
     Rows[b][2]:= Copy(s,j+1,(Length(s)-j)+1);
    end;

   XMLDocument1.Active:= false;
  end; {for}

end;
Сам к сожалению, не проверю - корпоративный файрвол с яндексом не дружит :-(
Ответить с цитированием