Difference between revisions of "FCL"

From Free Pascal wiki
(Category:Free Component Library)
m (Fixed syntax highlighting)
 
(22 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 
{{FCL}}
 
{{FCL}}
  
The ''Free Component Library'' (FCL) consists of a collection of units, providing components (mostly classes) for common tasks.
+
The ''Free Component Library'' ('''FCL''') consists of a collection of units, providing components (mostly classes) for common tasks. You can also see the [[LCL Components]] available directly within Lazarus. The FCL intends to be compatible with Delphi's ''Visual Component Library'' (VCL), but the FCL is restricted to non-visual components.
It intends to be compatible with Delphi's ''Visual Component Library'' (VCL), but the FCL is restricted to non-visual components.
 
 
On the other hand, the FCL also goes beyond the VCL.
 
On the other hand, the FCL also goes beyond the VCL.
  
See  [http://www.freepascal.org/fcl/fcl.html Free Component Library] for the current development status and an overview of the available components
+
See  [http://www.freepascal.org/fcl/fcl.var Free Component Library] for the current development status and an overview of the available components
(though this seems inconsistent with [http://lazarus-ccr.sourceforge.net/docs/fcl/index.html Reference for 'fcl'] in Lazarus).
+
(though this seems inconsistent with [http://lazarus-ccr.sourceforge.net/docs/fcl/index.html Reference for 'fcl'] in Lazarus). You can also check the [http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/packages/ source repository]. Note that there are also some platform-specific files in the FCL.
You can also check the [http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/packages/ source repository].
 
Note that there are also some platform-specific files in the FCL.
 
  
 
After the example, you can find a list of some FCL components.
 
After the example, you can find a list of some FCL components.
  
 
=== Usage ===
 
=== Usage ===
 
+
To use an FCL ''component'' you need to include the name of the [[Unit|unit]] which implemented it, in a '''uses''' clause in your program or unit (see example below).
To use an FCL component you need to include its name in a '''uses''' clause of your program or unit (see example below).
+
The default compiler [[Configuration file|configuration file]] is set up to search the FCL directories for such units.
The default compiler configuration is set up to search the fcl directory for such units.
 
 
You can also set the appropriate search path with a command-line compiler option of the form -Fu<path-to-fcl-units>.
 
You can also set the appropriate search path with a command-line compiler option of the form -Fu<path-to-fcl-units>.
  
 
=== Subpackages ===
 
=== Subpackages ===
  
Currently (future 2.2.2+) the FCL is divided into several subpackages:
+
The full list of subpackages of the FCL can be found here: [[Package List]]
 +
 
 +
The fcl-prefixed subpackages are:
  
* [[fcl-base]]    The base units  
+
* [[fcl-base]]    The base units (including e.g. an [[How To Use TFPExpressionParser|expression parser]])
 
* [[fcl-async]]    Asynchronous I/O (serial?)  
 
* [[fcl-async]]    Asynchronous I/O (serial?)  
 
* [[fcl-db]]      Generic database support + prepackaged drivers
 
* [[fcl-db]]      Generic database support + prepackaged drivers
 
* [[fcl-fpcunit]]  Unit testing framework
 
* [[fcl-fpcunit]]  Unit testing framework
* [[fcl-image]]    Image reading and writing (aka fpimage)
+
* [[fcl-image]]    Raster Image reading and writing (aka fpimage)
 
* [[fcl-json]]    Routines for javascript object streaming
 
* [[fcl-json]]    Routines for javascript object streaming
 
* [[fcl-net]]      Network related units
 
* [[fcl-net]]      Network related units
Line 32: Line 30:
 
* [[fcl-process]]  Process controll  
 
* [[fcl-process]]  Process controll  
 
* [[fcl-registry]] Registry  
 
* [[fcl-registry]] Registry  
 +
* [[fcl-res]]      Resource handling
 +
* [[fcl-stl]]      Generic container library (standard template library)
 
* [[fcl-web]]      Helper for web development
 
* [[fcl-web]]      Helper for web development
 
* [[fcl-xml]]      XML (DOM) unit and related units.
 
* [[fcl-xml]]      XML (DOM) unit and related units.
 
  
 
=== Documentation ===
 
=== Documentation ===
  
Currently, the FCL is not documented (feel free to contribute;
+
Currently, the FCL is not completely documented (feel free to contribute; also take a look at [[doc:fcl|Reference for 'fcl']]).
also take a look at [http://lazarus-ccr.sourceforge.net/docs/fcl/index.html Reference for 'fcl']).
 
 
For Delphi compatible units, you could consult the Delphi documentation.
 
For Delphi compatible units, you could consult the Delphi documentation.
 
You can always take a look at the source files in the [http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/packages/ source repository].
 
You can always take a look at the source files in the [http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/packages/ source repository].
Line 47: Line 45:
 
The following program illustrates the use of the class TObjectList in the FCL unit Contnrs (providing various containers, including lists, stacks, and queues):
 
The following program illustrates the use of the class TObjectList in the FCL unit Contnrs (providing various containers, including lists, stacks, and queues):
  
<delphi> program TObjectListExample;
+
<syntaxhighlight lang=pascal>
   
+
program TObjectListExample;
 +
  {$mode ObjFPC}
 
  uses
 
  uses
 
   Classes, { from RTL for TObject }
 
   Classes, { from RTL for TObject }
Line 72: Line 71:
 
   
 
   
 
  begin
 
  begin
   VObjectList := TObjectList.Create  { create an empty list }
+
   VObjectList := TObjectList.Create; { create an empty list }
 
   with VObjectList do
 
   with VObjectList do
 
   begin
 
   begin
Line 80: Line 79:
 
     Writeln((Last as TMyObject).Name);
 
     Writeln((Last as TMyObject).Name);
 
   end;
 
   end;
  end.</delphi>
+
  end.</syntaxhighlight>
  
 
This program must be compiled in an object-oriented mode, such as -Mobjfpc or -Mdelphi.
 
This program must be compiled in an object-oriented mode, such as -Mobjfpc or -Mdelphi.
Line 91: Line 90:
 
; Classes : Base classes for Object Pascal extensions in Delphi mode
 
; Classes : Base classes for Object Pascal extensions in Delphi mode
 
; Contnrs : Some common container classes
 
; Contnrs : Some common container classes
; FPCUnit : Unit testing framework (based on Kent Beck's unit testing framework, e.g. cf. [http://www.junit.org/ JUnit]), [http://www.freepascal.org/docs-html/fpcunit.pdf documenting article about FPCUnit]
+
; [[fpcunit|FPCUnit]] : A Unit testing framework (based on Kent Beck's unit testing framework. See [http://www.junit.org/ JUnit]),[http://www.freepascal.org/~michael/articles/fpcunit/fpcunit.pdf FPCUnit tutorial (pdf)]
 
; XMLRead, XMLWrite and DOM : Detailed at the [[XML Tutorial]]
 
; XMLRead, XMLWrite and DOM : Detailed at the [[XML Tutorial]]
[[Category:Free Component Library]]
 

Latest revision as of 23:41, 14 February 2020

Deutsch (de) English (en) español (es) suomi (fi) français (fr) Bahasa Indonesia (id) 日本語 (ja) русский (ru) 中文(中国大陆)‎ (zh_CN)

The Free Component Library (FCL) consists of a collection of units, providing components (mostly classes) for common tasks. You can also see the LCL Components available directly within Lazarus. The FCL intends to be compatible with Delphi's Visual Component Library (VCL), but the FCL is restricted to non-visual components. On the other hand, the FCL also goes beyond the VCL.

See Free Component Library for the current development status and an overview of the available components (though this seems inconsistent with Reference for 'fcl' in Lazarus). You can also check the source repository. Note that there are also some platform-specific files in the FCL.

After the example, you can find a list of some FCL components.

Usage

To use an FCL component you need to include the name of the unit which implemented it, in a uses clause in your program or unit (see example below). The default compiler configuration file is set up to search the FCL directories for such units. You can also set the appropriate search path with a command-line compiler option of the form -Fu<path-to-fcl-units>.

Subpackages

The full list of subpackages of the FCL can be found here: Package List

The fcl-prefixed subpackages are:

Documentation

Currently, the FCL is not completely documented (feel free to contribute; also take a look at Reference for 'fcl'). For Delphi compatible units, you could consult the Delphi documentation. You can always take a look at the source files in the source repository.

Example

The following program illustrates the use of the class TObjectList in the FCL unit Contnrs (providing various containers, including lists, stacks, and queues):

 program TObjectListExample;
 {$mode ObjFPC} 
 uses
   Classes, { from RTL for TObject }
   Contnrs; { from FCL for TObjectList }
 
 type
    TMyObject = class(TObject)  { just some application-specific class }
    private
      FName: String; { with a string field }
    public
      constructor Create(AName: String); { and a constructor to create it with a given name }
      property Name: String read FName; { and a property to read the name }
   end;
 
 constructor TMyObject.Create(AName: String);
 begin
   inherited Create;
   FName := AName;
 end;
 
 var
   VObjectList: TObjectList; { for a list of objects; it is a reference to such a list! }
 
 begin
   VObjectList := TObjectList.Create;  { create an empty list }
   with VObjectList do
   begin
     Add(TMyObject.Create('Thing One'));
     Writeln((Last as TMyObject).Name);
     Add(TMyObject.Create('Thing Two'));
     Writeln((Last as TMyObject).Name);
   end;
 end.

This program must be compiled in an object-oriented mode, such as -Mobjfpc or -Mdelphi.

FCL Components

This is not an exhaustive list (to avoid duplication of effort). It only mentions some important components, or components that are otherwise not easy to find.

Classes 
Base classes for Object Pascal extensions in Delphi mode
Contnrs 
Some common container classes
FPCUnit 
A Unit testing framework (based on Kent Beck's unit testing framework. See JUnit),FPCUnit tutorial (pdf)
XMLRead, XMLWrite and DOM 
Detailed at the XML Tutorial