Nahum Wild asked:
> Currently I'm just forcibly casting at runtime the objects to
> the interface
> and trapping the exception generated if it don't work.
>
> for i := fUndoList.Count-1 do begin
> try
> (fMyList[i] as ICommandInterface).Prune;
> except
> on E: EIntfCastError do begin
> // do nothing
> end;
> end;
> end;
>
> This is pretty yuck and want to do it a better/nicer way. Does
> anybody know
> what I'm taking about and/or can help??
Use Supports, as in
var
Command: ICommandInterface;
I: Integer;
begin
for i := fUndoList.Count-1 do
if Supports(fMyList[I], ICommandInterface, Command) then
Command.Prune
Declared in SysUtils I think.
Cheers, Max.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"