<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi<br>
<br>
Yeah I read examples of how to add enumerators but since TObjectList
already has one I didn't think I needed to.&nbsp; Guess I do.&nbsp; Seems like it
is a bit too much work for basic (small) classes not frequently used
(such as the one im working on).&nbsp; Will give it a go anyway :)<br>
<br>
Thanks<br>
Rob<br>
<div class="moz-signature">
<div class="Section1"><br>
<p class="MsoNormal"><span style="color: rgb(255, 153, 0);" lang="EN-NZ"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="" lang="EN-NZ"><o:p>&nbsp;</o:p></span></p>
</div>
</div>
<br>
<br>
Jolyon Smith wrote:
<blockquote cite="mid:004901ca4d15$f5e0c1c0$e1a24540$@co.nz" type="cite">
  <pre wrap="">You will have to implement an enumerator for your TCountryAddressFormats
class that returns TCountryAddressFormat references.

This isn't a language feature that "just works" - you have to put some
infrastructure in place to support it.

The feature appears to "just work" for a bunch of VCL types (TStringList
etc) because the VCL already contains the necessary infrastructure additions
(and which should provide the examplar implementations on which you could
base your own).


-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a> [<a class="moz-txt-link-freetext" href="mailto:delphi-bounces@delphi.org.nz">mailto:delphi-bounces@delphi.org.nz</a>] On
Behalf Of Robert martin
Sent: Thursday, 15 October 2009 10:06 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Stupid /easy question

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

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject:
unsubscribe

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe

  </pre>
</blockquote>
</body>
</html>