[fpc-pascal] Overriding or reimplementing a property

Marco van de Voort marcov at stack.nl
Sat Mar 2 00:09:25 CET 2013


In our previous episode, Mark Morgan Lloyd said:
> Given something like
> 
> implementation
> 
> var     DBConnectionNearby: TSQLConnection= nil;
> 
> ..
> case MainForm.NearbyKind of
>    dbkFirebird: DBConnectionNearby := TIBConnection.Create(nil);
>    dbkPostgres: DBConnectionNearby := TPQConnection.Create(nil);
> 
> is there an elegant way of overriding the Connected property to point to 
> code that can e.g. check that all prerequisite libraries are available 
> before trying to activate the object?

Check the prequisite libraries yourself, and then if found, initialize the
corresponding unit yourself:

e.g. in the case of postgres3dyn using

Function InitialisePostgres3(Const libpath : ansistring) : integer;




More information about the fpc-pascal mailing list