noname_06
18-01-2009, 17:42
В TMemo из файла загружен список файлов в виде [Линк |размер дата время]. Нужно чтобы в StringGrid в первом столбце были обработаные адреса файлов, а в втором - размер. Пробовал так:
procedure TForm1.RunBtnClick(Sender: TObject); {обработка файла}
var i, j, position, strlenght, x, y, w, MaxWidth: integer;
currstr, s: string;
begin
StringGrid.Visible:= true;
for j:=1 to 2 do {заполняется первый столбец, потом второй}
begin
for i:=1 to StringGrid.RowCount+1 do
begin
currstr:= Memo.Lines[i-1]; {получаем текущую строку}
strlenght:= length(currstr); {длина}
position:= pos(' |', currstr); {позиция конца адреса в строке}
if j=1 then {для первого столбца оставляем только линк}
begin
delete(currstr, position, strlenght-position+1);
currstr:= concat(EditPatch.text, currstr);
end
else {для второго солбца оставляем только размер файла}
begin
delete(currstr, 1, position+1);
position:= pos(' ', currstr);
delete(currstr, position, strlenght-position+1);
currstr:= IntToStr(StrToInt(currstr) div 1024 div 1024) + 'Mb';
end;
StringGrid.Cells[j,i]:= currstr; {заполняем ячейку}
if j=1 then ProgressBar.Position := 100 * i div StringGrid.RowCount
else ProgressBar.Position := 50 + 100 * i div StringGrid.RowCount
end;
end;
with StringGrid do {установить ширину ячеек по макс. ширине текста}
ClientHeight:= DefaultRowHeight * RowCount + 5;
with StringGrid do
begin
for x := 0 to ColCount - 1 do
begin
MaxWidth := 0;
for y := 0 to RowCount - 1 do
begin
w := Canvas.TextWidth(Cells[x,y]);
if w > MaxWidth then
MaxWidth := w;
end;
ColWidths[x] := MaxWidth + 5;
end;
end; {конец установки}
end;
При нажатии на кнопку выбрасывает ошибку:
Debugger Exeption Notificetion
Project ***** raised exeprion class EConvertError with message "is not a valid integer value"
з.ы. и ещё - как лучше напрямую прочитать/записать данные в StringGrid из текстового файла? (подразумевается обработка по 5-30 тыс. строк текста)
з.з.ы. как правильно прикрутить к проэкту XPManifest? простым добавлением на форму не хочет. Среда Delphi 7.0
procedure TForm1.RunBtnClick(Sender: TObject); {обработка файла}
var i, j, position, strlenght, x, y, w, MaxWidth: integer;
currstr, s: string;
begin
StringGrid.Visible:= true;
for j:=1 to 2 do {заполняется первый столбец, потом второй}
begin
for i:=1 to StringGrid.RowCount+1 do
begin
currstr:= Memo.Lines[i-1]; {получаем текущую строку}
strlenght:= length(currstr); {длина}
position:= pos(' |', currstr); {позиция конца адреса в строке}
if j=1 then {для первого столбца оставляем только линк}
begin
delete(currstr, position, strlenght-position+1);
currstr:= concat(EditPatch.text, currstr);
end
else {для второго солбца оставляем только размер файла}
begin
delete(currstr, 1, position+1);
position:= pos(' ', currstr);
delete(currstr, position, strlenght-position+1);
currstr:= IntToStr(StrToInt(currstr) div 1024 div 1024) + 'Mb';
end;
StringGrid.Cells[j,i]:= currstr; {заполняем ячейку}
if j=1 then ProgressBar.Position := 100 * i div StringGrid.RowCount
else ProgressBar.Position := 50 + 100 * i div StringGrid.RowCount
end;
end;
with StringGrid do {установить ширину ячеек по макс. ширине текста}
ClientHeight:= DefaultRowHeight * RowCount + 5;
with StringGrid do
begin
for x := 0 to ColCount - 1 do
begin
MaxWidth := 0;
for y := 0 to RowCount - 1 do
begin
w := Canvas.TextWidth(Cells[x,y]);
if w > MaxWidth then
MaxWidth := w;
end;
ColWidths[x] := MaxWidth + 5;
end;
end; {конец установки}
end;
При нажатии на кнопку выбрасывает ошибку:
Debugger Exeption Notificetion
Project ***** raised exeprion class EConvertError with message "is not a valid integer value"
з.ы. и ещё - как лучше напрямую прочитать/записать данные в StringGrid из текстового файла? (подразумевается обработка по 5-30 тыс. строк текста)
з.з.ы. как правильно прикрутить к проэкту XPManifest? простым добавлением на форму не хочет. Среда Delphi 7.0