A nie jest tak, że jak nie przypisze nil do wskaźnika to gdy do niego sięgnę, żeby, np. sprawdzić czy nie jest nilowy to nie wysypie się program bo sięgnę do nieprzydielonego mi obszaru pamięci ?
Mniej wiecej wiem o co chodzi ale mam problem ze swoim kodem. Kod jest mniej więcej taki :
type
PricingPosition = record
nazwa: AnsiString;
grupa: AnsiString;
cenaMin: Currency;
cenaMax: Currency;
end;
p_PricingPosition = ^PricingPosition;
...
function TBrowseVendors.Parse(ToParse: AnsiString): TList;
var
substring, subcell: AnsiString;
I, J, p: integer;
Positions: TList;
pPos : p_PricingPosition;
const
HeaderTag = '<tr class="tabela_cennik_naglowek">';
PositionTag = '<tr class="tabela_cennik_pole">';
EndOfColTag = '</td>';
begin
Positions := TList.Create;
for I := 1 to Length(ToParse) do
begin
substring := substring + ToParse[I];
if Pos(PositionTag, substring) > 0 then
begin
Delete(substring, Length(substring) - 36, 36);
if Pos(HeaderTag, substring) = 0 then
begin
p := 0;
for J := 1 to Length(substring) do
begin
subcell := subcell + substring[J];
New(pPos);
if Pos(EndOfColTag,subcell) > 0 then
begin
Trim(subcell);
Delete(subcell,1,4);
Delete(subcell,Length(subcell) - 4,5);
case p of
0 : pPos^.nazwa := subcell;
1 : pPos^.grupa := subcell;
2 : pPos^.cenaMin := Currency(subcell);
3 : pPos^.cenaMax := Currency(subcell);
end;
subcell := '' ;
inc(p);
end;
Positions.Add(pPos);
pPos := nil;
end;
subcell := '' ;
end;
substring := '';
end;
end;
For I:=0 to Positions.Count do
begin
ShowMessage(p_PricingPosition(Positions[i])^.nazwa );
end;
end;
Problem w tym, że jak ostatnią pętlą chodzę bo kolekcji i ją wyrzucam MessageBoxem to nic tam nie ma albo są śmieci - co robię źle ??