[fpc-pascal] problem with interface (OOP not widget)

Michael Van Canneyt michael at freepascal.org
Wed Jan 23 09:12:17 CET 2008



On Wed, 23 Jan 2008, Bee wrote:

> Hi all,
> 
> I got problem with the code below.
> 
> --->8--- begin code --->8---
> 
> program test_intf_query;
> 
> {$IFDEF FPC}
>   {$MODE OBJFPC}{$H+}
> {$ENDIF}
> 
> uses
>   Classes;
> 
> type
>   TPLFieldType = (plftUnknown, plftString, plftSmallint, plftInteger,
>     plftWord, plftBoolean, plftFloat, plftCurrency, plftBCD, plftDate,
>     plftTime, plftDateTime, plftBytes, plftVarBytes, plftAutoInc,
>     plftBlob, plftMemo, plftGraphic, plftFmtMemo, plftParadoxOle,
>     plftDBaseOle, plftTypedBinary, plftCursor, plftFixedChar,
>     plftWideString, plftLargeint, plftADT, plftArray, plftReference,
>     plftDataSet, plftOraBlob, plftOraClob, plftVariant, plftInterface,
>     plftIDispatch, plftGuid, plftTimeStamp, plftFMTBcd,
>     plftFixedWideChar, plftWideMemo, plftOraTimeStamp, plftOraInterval);
> 
>   ISimple = interface
>   ['{24811FF3-4F01-4601-AC5C-22A5B5D46928}']
>     function ShowSomething: Integer; cdecl;
>     function GetIsBlob: Boolean; cdecl;
>   end;
> 
>   TSimple = class(TInterfacedObject, ISimple)
>   private
>     FDataType: TPLFieldType;
>   protected
>     { ISimple implementation }
>     function ShowSomething: Integer; cdecl;
>     function GetIsBlob: Boolean; cdecl;
>   end;
> 
> { query ISimple }
> function QuerySimple(const OnChange: TNotifyEvent = nil): ISimple;
>   cdecl;
> begin
>   Result := TSimple.Create;
> end;
> 
> {*** TSimple ***}
> 
> function TSimple.ShowSomething: Integer; cdecl;
> begin
>   Writeln('Message from ISimple');
>   Result := 0;
> end;
> 
> function TSimple.GetIsBlob: Boolean; cdecl;
> begin
>   Result := FDataType in [
>             plftBytes, plftVarBytes, plftBlob, plftMemo, plftGraphic,
>             plftFmtMemo, plftParadoxOle, plftDBaseOle, plftTypedBinary,
>             plftOraClob, plftOraClob, plftWideMemo
You have
  plftOraClob, plftOraClob

2 times the same element. This is not allowed.

Michael.



More information about the fpc-pascal mailing list