Difference between revisions of "FCL"

From Lazarus wiki
Jump to navigationJump to search
m (Included link to "Reference for package 'fcl'" in Lazarus doc)
m (Corrected links to FCL in the source repository)
Line 5: Line 5:
 
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.html 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/fcl/inc/ source repository].
+
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, which you can find under trunk/fcl/<platform>/.
 
Note that there are also some platform specific files in the FCL, which you can find under trunk/fcl/<platform>/.
  
Line 19: Line 19:
 
also take a look at [http://lazarus-ccr.sourceforge.net/docs/fcl/index.html 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/fcl/inc/ 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].
  
 
=== Example ===
 
=== Example ===

Revision as of 23:49, 12 June 2007

The Free Component Library (FCL) consists of a collection of units, providing components (mostly classes) for common tasks. 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.

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, which you can find under trunk/fcl/<platform>/.

Usage

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 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>.

Documentation

Currently, the FCL is not 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;

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.