[DUG] Stupid /easy question
Robert martin
rob at chreos.co.nz
Thu Oct 15 10:06:14 NZDT 2009
Hi
After the D2010 presentation yesterday I decided I should actually use
some of the D2007 features I had not gotten around to using.
Specifically the For .. in construct.
I am sure I am missing something but here iss what I want to do
I have the following 'old school code' (note the base class here
inherits from TObjectList)
procedure TCountryAddressFormats.LoadStringListWithCompanies(Strings:
TStrings);
var
Counter : Integer;
begin
for Counter := 0 to Self.Count - 1 do begin
Strings.AddObject(
TCountryAddressFormat(Self.Items[Counter]).CountryName,
Tobject(TCountryAddressFormat(Self.Items[Counter]).CountryRefAsInteger) );
end;
end;
I wanted to replace it with
procedure TCountryAddressFormats.LoadStringListWithCompanies(Strings:
TStrings);
var
CountryAddressFormat : TCountryAddressFormat;
begin
for CountryAddressFormat in Self do begin
Strings.AddObject( CountryAddressFormat.CountryName,
TObject(CountryAddressFormat.CountryRefAsInteger) );
end;
end;
but I get the following error
[DCC Error] AddressFormat.pas(157): E2010 Incompatible types:
'TCountryAddressFormat' and 'Pointer'
what am I missing ?
Cheers
Rob
More information about the Delphi
mailing list