Harbour is a computer
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
, used mainly to create database/business programs. It is a modernised
cross-platform
Within computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several Computing platform, computing platforms. Some ...
version of the older
Clipper
A clipper was a type of mid-19th-century merchant sailing vessel, designed for speed. The term was also retrospectively applied to the Baltimore clipper, which originated in the late 18th century.
Clippers were generally narrow for their len ...
system, which in turn developed from the
dBase
dBase (also stylized dBASE) was one of the first database management systems for microcomputers and the most successful in its day. The dBase system included the core database engine, a query system, a Form (programming), forms engine, and a pr ...
database market of the 1980s and 1990s. It is
free and open-source software
Free and open-source software (FOSS) is software available under a license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term encompassing free ...
which license is
GNU General Public License
The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
(GPL) compatible.
Harbour code uses the same databases and can be compiled under a wide variety of platforms, including
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
,
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
variants, several
Berkeley Software Distribution
The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginn ...
(BSD) descendants,
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
,
Minix 3,
Windows CE
Windows CE, later known as Windows Embedded CE and Windows Embedded Compact, is a discontinued operating system developed by Microsoft for mobile and embedded devices. It was part of the Windows Embedded family and served as the software foun ...
,
Pocket PC
A Pocket PC (P/PC, PPC) is a class of personal digital assistant (PDA) that runs the Windows Mobile operating system, which is based on Windows Embedded Compact, Windows CE/Windows Embedded Compact, and that has some of the abilities of modern ...
,
Symbian
Symbian is a discontinued mobile operating system (OS) and computing platform designed for smartphones. It was originally developed as a proprietary software OS for personal digital assistants in 1998 by the Symbian Ltd. consortium. Symbian OS ...
,
iOS
Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...
,
Android,
QNX,
VxWorks
VxWorks is a real-time operating system (or RTOS) developed as proprietary software by Wind River Systems, a subsidiary of Aptiv. First released in 1987, VxWorks is designed for use in embedded systems requiring real-time, Deterministic system, ...
,
OS/2
OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
(including
eComStation
eComStation or eCS is an operating system based on OS/2 Warp for the 32-bit x86 architecture. It was originally developed by Serenity Systems and Mensys BV under license from IBM. It includes additional applications, and support for new hardwa ...
and
ArcaOS
ArcaOS is a Proprietary software, proprietary operating system based on OS/2, developed and marketed by Arca Noae, LLC under license from IBM. It was first released in 2017 and builds on OS/2 Warp 4.52 by adding support for new hardware, fixing ...
),
BeOS
BeOS is a discontinued operating system for personal computers that was developed by Be Inc. It was conceived for the company's BeBox personal computer which was released in 1995. BeOS was designed for multitasking, multithreading, and a graph ...
–
Haiku
is a type of short form poetry that originated in Japan. Traditional Japanese haiku consist of three phrases composed of 17 Mora (linguistics), morae (called ''On (Japanese prosody), on'' in Japanese) in a 5, 7, 5 pattern; that include a ''kire ...
,
AIX
Aix or AIX may refer to:
Computing
* AIX, a line of IBM computer operating systems
*Alternate index, for an IBM Virtual Storage Access Method key-sequenced data set
* Athens Internet Exchange, a European Internet exchange point
Places Belg ...
, and
DOS
DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
.
History
The idea of a free software Clipper compiler had been arising for a long time and the subject occurred often in discussion on comp.lang.clipper. Antonio Linares founded the Harbour project and the implementation was started in March 1999. The name "Harbour" was proposed by Linares, it is a play on a
Clipper
A clipper was a type of mid-19th-century merchant sailing vessel, designed for speed. The term was also retrospectively applied to the Baltimore clipper, which originated in the late 18th century.
Clippers were generally narrow for their len ...
as a type of ship. Harbour is a synonym for port (where ships dock), and Harbour is a port of the Clipper language.
In 2009, Harbour was substantially redesigned, mainly by Viktor Szakáts and Przemyslaw Czerpak.
Database support
Harbour extends the Clipper Replaceable Database Drivers (RDD) approach. It offers multiple RDDs such as
dBase
dBase (also stylized dBASE) was one of the first database management systems for microcomputers and the most successful in its day. The dBase system included the core database engine, a query system, a Form (programming), forms engine, and a pr ...
(DBF), DBFNTX, DBFCDX, DBFDBT and DBFFPT. In Harbour, multiple RDDs can be used in one application, and new logical RDDs can be defined by combining other RDDs. The RDD architecture allows for
inheritance
Inheritance is the practice of receiving private property, titles, debts, entitlements, privileges, rights, and obligations upon the death of an individual. The rules of inheritance differ among societies and have changed over time. Offi ...
, so that a given RDD may extend the functions of other existing RDD(s). Third-party RDDs, like RDDSQL, RDDSIX, RMDBFCDX,
Advantage Database Server
Sap is a fluid transported in the xylem cells (vessel elements or tracheids) or phloem sieve tube elements of a plant. These cells transport water and nutrients throughout the plant.
Sap is distinct from latex, resin, or cell sap; it is a sep ...
, and Mediator exemplify some of the RDD architecture features. DBFNTX implementation has almost the same functionality of DBFCDX and RDDSIX. NETIO and LetoDB provide remote access over
Transmission Control Protocol
The Transmission Control Protocol (TCP) is one of the main communications protocol, protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, th ...
(TCP).
Harbour also offers
ODBC
In computing, Open Database Connectivity (ODBC) is a standard application programming interface (API) for accessing database management systems (DBMS). The designers of ODBC aimed to make it independent of database systems and operating systems. An ...
support by means of an
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
(OOP) syntax, and
ActiveX Data Objects
In computing, Microsoft's ActiveX Data Objects (ADO) comprises a set of Component Object Model (COM) objects for accessing data sources. A part of MDAC (Microsoft Data Access Components), it provides a middleware layer between programming la ...
(ADO) support by means of
OLE Automation
In Microsoft Windows applications programming, OLE Automation (later renamed to simply Automation) is an inter-process communication mechanism created by Microsoft. It is based on a subset of Component Object Model (COM) that was intended for use ...
(OLE).
MySQL
MySQL () is an Open-source software, open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A rel ...
,
PostgreSQL
PostgreSQL ( ) also known as Postgres, is a free and open-source software, free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. PostgreSQL features transaction processing, transactions ...
,
SQLite
SQLite ( "S-Q-L-ite", "sequel-ite") is a free and open-source relational database engine written in the C programming language. It is not a standalone app; rather, it is a library that software developers embed in their apps. As such, it ...
,
Firebird
Firebird and fire bird may refer to:
Mythical birds
* Phoenix (mythology), sacred firebird found in the mythologies of many cultures
** Fenghuang, sometimes called Chinese phoenix
* Vermilion bird, one of the four symbols of the Chinese constella ...
,
Oracle
An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination.
Descript ...
are examples of databases which Harbour can connect to.
xBase
xBase is the generic term for all programming languages that derive from the original dBASE (Ashton-Tate) programming language and database formats. These are sometimes informally known as dBASE "clones". While there was a non-commercial predec ...
technologies are confused often with
relational database management system
A relational database (RDB) is a database based on the relational model of data, as proposed by E. F. Codd in 1970.
A Relational Database Management System (RDBMS) is a type of database management system that stores data in a structured for ...
(RDBMS) software. While xBase was promoted as relational, xBase is more than a simple database system, as at the same time, xBase languages using purely DBF cannot provide the full features of a full RDBMS.
Programming philosophy
Harbour aims to be
written once, compiled anywhere. As the same compiler is available for all of the above operating systems, there is no need for re-coding to produce identical products for different platforms, except when operating system dependent features are used. Cross-compiling is supported with
MinGW
MinGW ("Minimalist GNU for Windows"), formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications.
MinGW includes a port of the GNU Compiler Collection (GCC), GNU Binutils for Windows ...
. Under Microsoft Windows, Harbour is more stable but less well-documented than Clipper, but has multi-platform ability and is more transparent, allows for more customisation and can run from a USB flash drive.
Under Linux and Windows Mobile, Clipper source code can be compiled with Harbour with very little adaptation. Most software originally written to run on Xbase++, FlagShip, FoxPro, xHarbour and others dialects can be compiled with Harbor with some adaptation. As of 2010 many efforts have been made to make the transition from other
xBase
xBase is the generic term for all programming languages that derive from the original dBASE (Ashton-Tate) programming language and database formats. These are sometimes informally known as dBASE "clones". While there was a non-commercial predec ...
dialects easier.
Harbour can use the following C compilers, among others:
GCC,
MinGW
MinGW ("Minimalist GNU for Windows"), formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications.
MinGW includes a port of the GNU Compiler Collection (GCC), GNU Binutils for Windows ...
,
Clang
Clang () is a compiler front end for the programming languages C, C++, Objective-C, Objective-C++, and the software frameworks OpenMP, OpenCL, RenderScript, CUDA, SYCL, and HIP. It acts as a drop-in replacement for the GNU Compiler ...
,
Intel C++ Compiler
Intel oneAPI DPC++/C++ Compiler and Intel C++ Compiler Classic (deprecated icc and icl is in Intel OneAPI HPC toolkit) are Intel’s C, C++, SYCL, and Data Parallel C++ (DPC++) compilers for Intel processor-based systems, available for Wind ...
(ICC),
Microsoft Visual C++
Microsoft Visual C++ (MSVC) is a compiler for the C, C++, C++/CLI and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available i ...
(6.0+),
Borland C++
Borland C++ was a C and C++ IDE (integrated development environment) released by Borland for MS-DOS and Microsoft Windows. It was the successor to Turbo C++ and included a better debugger, the Turbo Debugger, which was written in protected mo ...
,
Watcom C,
Pelles C and
Sun Studio
Sun Studio is a recording studio opened by rock-and-roll pioneer Sam Phillips at 706 Union Avenue in Memphis, Tennessee, on January 3, 1950. It was originally called Memphis Recording Service, sharing the same building with the Sun Records la ...
.
Harbour can make use of multiple Graphical Terminal emulation, including console drivers, and Hybrid Console/GUIs, such as GTWvt, and GTWvg.
Harbour supports external GUI's, free (e.g. HBQt, HWGui, Mini-GUI (latest version based on Qt and QtContribs) and commercial (e.g. FiveWin, Xailer). HBQt is a library providing bindings to Qt. HBIDE application is a sample of HBQt potential.
Harbour is 100% Clipper-compatible and supports many language syntax extensions including greatly extended run-time libraries such as
OLE
OLE, Ole or Olé may refer to:
* Olé, a cheering expression used in Spain
* Ole (name), a male given name, includes a list of people named Ole
* Overhead lines equipment, used to transmit electrical energy to trams, trolleybuses or trains
Co ...
, Blat,
OpenSSL
OpenSSL is a software library for applications that provide secure communications over computer networks against eavesdropping, and identify the party at the other end. It is widely used by Internet servers, including the majority of HTTPS web ...
, Free Image,
GD, hbtip, hbtpathy,
PCRE
Perl Compatible Regular Expressions (PCRE) is a library written in C, which implements a regular expression engine, inspired by the capabilities of the Perl programming language. Philip Hazel started writing PCRE in summer 1997. PCRE's synta ...
, hbmzip (
zlib
zlib ( or "zeta-lib", ) is a software library used for data compression as well as a data format. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compre ...
), hbbz2 (
bzip2
bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities such as tar for tasks such as handli ...
),
cURL
cURL (pronounced like "curl", ) is a free and open source computer program for transferring data to and from Internet servers. It can download a URL from a web server over HTTP, and supports a variety of other network protocols, URI scheme ...
,
Cairo
Cairo ( ; , ) is the Capital city, capital and largest city of Egypt and the Cairo Governorate, being home to more than 10 million people. It is also part of the List of urban agglomerations in Africa, largest urban agglomeration in Africa, L ...
, its own implementation of CA-Tools, updated NanFor libraries and many others. Harbour has an active development community and extensive third party support.
Any
xBase
xBase is the generic term for all programming languages that derive from the original dBASE (Ashton-Tate) programming language and database formats. These are sometimes informally known as dBASE "clones". While there was a non-commercial predec ...
language provides a very productive way to build business and data intensive applications. Harbour is not an exception.
Macro operator (runtime compiler)
One of the most powerful features of xBase languages is the
Macro Operator '&'. Harbour's implementation of the Macro Operator allows for runtime compilation of any valid Harbour expression. Such a compiled expression may be used as a VALUE, i.e. the right side of an assignment (rvalue) or may be used to resolve the left side (lvalue) of an assignment, i.e. private, or public variables, or a database field.
Additionally, the Macro Operator may compile and execute function calls, complete assignments, or even list of arguments, and the result may be used to resolve any of the above contexts in the compiled application.
The latest Macro compiler can compile any valid Harbour code including code to per-process before compile.
Syntax:
&( ... )
The text value of the expression '...' will be compiled, and the value resulting from the execution of the compiled code is the result.
&SomeId
is the short form for &( SomeId ).
&SomeId.postfix
is the short form of &( SomeId + "postfix" ).
Object-oriented programming
Programming in an OOP style is a broader issue than a specific library or a specific interface, but OOP programming is something many Clipper programmers have come to expect. CA-Clipper 5.2 and especially 5.3 added a number of base classes, and a matching OOP syntax. Libraries such a
Class(y) FieWin, Clip4Win, and Top Class provide additional OOP functionality.
Harbour has OOP extensions with full support for classes including inheritance, based on Class(y) syntax. OOP syntax in Harbour is very similar to that of earlier Clipper class libraries so it should be possible to maintain legacy Clipper code with minimal changes.
Syntax and semantics

Harbour as every xBase language is case insensitive and can optionally accept keywords written just by their first four characters.
Built-in data types
Harbour has six scalar types:
Nil,
String
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
,
Date,
Logical
Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the study of deductively valid inferences or logical truths. It examines how conclusions follow from premises based on the structure of arg ...
,
Numeric,
Pointer, and four complex types:
Array
An array is a systematic arrangement of similar objects, usually in rows and columns.
Things called an array include:
{{TOC right
Music
* In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
,
Object
Object may refer to:
General meanings
* Object (philosophy), a thing, being, or concept
** Object (abstract), an object which does not exist at any particular time or place
** Physical object, an identifiable collection of matter
* Goal, an a ...
,
CodeBlock, and
Hash
Hash, hashes, hash mark, or hashing may refer to:
Substances
* Hash (food), a coarse mixture of ingredients, often based on minced meat
* Hash (stew), a pork and onion-based gravy found in South Carolina
* Hash, a nickname for hashish, a canna ...
. A scalar holds a single value, such as a string, numeric, or reference to any other type. Arrays are ordered lists of scalars or complex types, indexed by number, starting at 1. Hashes, or
associative array
In computer science, an associative array, key-value store, map, symbol table, or dictionary is an abstract data type that stores a collection of (key, value) pairs, such that each possible key appears at most once in the collection. In math ...
s, are unordered collections of any type values indexed by their associated key, which may be of any scalar or complex type.
Literal (static) representation of scalar types:
* Nil:
* String:
* Date:
* Logical:
* Numeric:
Complex Types may also be represent as literal values:
* Array:
*
CodeBlock:
* Hash:
Hashes may use ''any'' type including other Hashes as the ''Key'' for any element. Hashes and Arrays may contain ''any'' type as the ''Value'' of any member, including nesting arrays, and Hashes.
Codeblocks may have references to Variables of the Procedure/Function>method in which it was defined. Such Codeblocks may be returned as a value, or by means of an argument passed , in such case the Codeblock will "outlive" the routine in which it was defined, and any variables it references, will be a variable.
Detached variables will maintain their value for as long as a Codeblock referencing them still exists. Such values will be shared with any other Codeblock which may have access to those same variables. If the Codeblock did not outlive its containing routine, and will be evaluated within the lifetime of the routine in which it is defined, changes to its ''Detached Variables''(s) by means of its evaluation, will be reflected back at its parent routine.
Codeblocks can be evaluated any number of times, by means of the function.
Variables
All types can be assigned to named variables. Named variable identifiers are 1 to 63 ASCII characters long, start with
_/code> and further consist of the characters 0–9, _/code> up to a maximum of 63 characters. Named variables are not case sensitive.
Variables have one of the following scopes:
* : Visible only within the routine which declared it. Value is lost upon exit of the routine.
* : Visible only within the routine which declared it. Value is preserved for subsequent invocations of the routine. If a STATIC variable is declared before any Procedure/Function/Method is defined, it has a MODULE scope, and is visible within any routine defined within that same source file, it will maintain its life for the duration of the application lifetime.
* : Visible within the routine which declared it, and all routines by that routine.
* : Visible by routines in the same application.
and are resolved at compile time, and thus are much faster than and variables which are dynamic entities accessed by means of a runtime Symbol table
In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier, symbol, constant, procedure and function in a program's source code is associated with information ...
. For this same reason, and variables are exposed to the Macro compiler, and any macro code which attempts to reference them will generate a runtime error.
Due to the dynamic nature of and variables, they can be created and destroyed at runtime and can be accessed and modified by means of runtime macros or by Codeblocks created on the fly.
Control structures
The basic control structures include all of the standard dBase
dBase (also stylized dBASE) was one of the first database management systems for microcomputers and the most successful in its day. The dBase system included the core database engine, a query system, a Form (programming), forms engine, and a pr ...
, and Clipper
A clipper was a type of mid-19th-century merchant sailing vessel, designed for speed. The term was also retrospectively applied to the Baltimore clipper, which originated in the late 18th century.
Clippers were generally narrow for their len ...
control structures as well as additional ones inspired by the C or Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
programming languages:
Loops
OWHILE ''ConditionExp''
''...''
OOP XIT END O
FOR ''Var'' := ''InitExp'' TO ''EndExp'' TEP ''StepExp''
TEP may refer to:
Businesses and organizations
*TEP, the Society of Trust and Estate Practitioners members' post-nominal
*Tallgrass Energy Partners, an American oil and gas pipeline company
*Tau Epsilon Phi, a fraternity
*Transatlantic Economic P ...
''...''
OOP XIT NEXT
FOR EACH ''Var'' IN ''CollectionExp''
''...''
'Var'':__enumIndex() OOP XIT NEXT
* The ''...'' is a sequence of one or more Harbour statements, and square brackets []
denote optional syntax.
* The ''Var'':__enumIndex() may be optionally used to retrieve the current iteration index (1 based).
* The ''LOOP'' statement restarts the current iteration of the enclosing loop structure, and if the enclosing loop is a ''FOR'' or ''FOR EACH'' loop, it increases the iterator, moving to the next iteration of the loop.
* The ''EXIT'' statement immediately terminates execution of the enclosing loop structure.
* The ''NEXT'' statement closes the control structure and moves to the next iteration of loop structure.
In the ''FOR'' statement, the ''assignment'' expression is evaluated prior to the first loop iteration. The ''TO'' expression is evaluated and compared against the value of the control variable, prior to each iteration, and the loop is terminated if it evaluates to a numeric value greater than the numeric value of the control variable. The optional ''STEP'' expression is evaluated after each iteration, prior to deciding whether to perform the next iteration.
In ''FOR EACH'', the ''Var'' variable will have the value (scalar, or complex) of the respective element in the collection value. The collection expression may be an Array (of any type or combinations of types), a Hash Table, or an Object type.
IF statements
IF ''CondExp''
''...''
LSEIF''CondExp''
''...''
LSE ''...''
END F
''...'' represents 0 or more ''statement(s)''.
The condition expression(s) has to evaluate to a ''LOGICAL'' value.
SWITCH statements
Harbour supports a SWITCH construct inspired by the C implementation of switch().
SWITCH ''SwitchExp''
CASE ''LiteralExp''
''...''
XIT ASE ''LiteralExp'' ''...''
XIT THERWISE ''...''
ENDWITCH
Witchcraft is the use of magic by a person called a witch. Traditionally, "witchcraft" means the use of magic to inflict supernatural harm or misfortune on others, and this remains the most common and widespread meaning. According to ''Enc ...
* The ''LiteralExp'' must be a compiled time resolvable numeric expression, and may involve operators, as long as such operators involve compile time static value.
* The ''EXIT'' optional statement is the equivalent of the C statement ''break'', and if present, execution of the SWITCH structure will end when the EXIT statement is reached, otherwise it will continue with the first statement below the next CASE statement (fall through).
BEGIN SEQUENCE statements
BEGIN SEQUENCE
''...''
REAK reak( [''Exp'')">'Exp''.html" ;"title="reak( [''Exp''">reak( [''Exp'') RECOVER [USING ''Var''">'Exp''">reak(_[''Exp''<_a>).html" ;"title="'Exp''.html" ;"title="reak( [''Exp''">reak( [''Exp'')">'Exp''.html" ;"title="reak( [''Exp''">reak( [''Exp'') RECOVER [USING ''Var'' ''...''
END[SEQUENCE]
or:
BEGIN SEQUENCE
''...''
REAK [Break()]
END[SEQUENCE]
The BEGIN SEQUENCE structure allows for a well behaved abortion of any sequence, even when crossing nested procedures/functions. This means that a called procedure/function, may issue a BREAK statement, or a Break() expression, to force unfolding of any nested procedure/functions, all the way back to the first outer BEGIN SEQUENCE structure, either after its respective END statement, or a RECOVER clause if present. The Break statement may optionally pass any type of expression, which may be accepted by the RECOVER statement to allow further recovery handling.
Additionally the Harbour ''Error Object'' supports ''canDefault'', ''canRetry'' and ''canSubstitute'' properties, which allows error handlers to perform some preparations, and then request a ''Retry Operation'', a ''Resume'', or return a Value to replace the expression triggering the error condition.
Alternatively TRY ATCH INALLYstatements are available on ''xhb'' library working like the SEQUENCE construct.
Procedures and functions
TATICPROCEDURE ''SomeProcedureName''
TATICPROCEDURE ''SomeProcedureName''()
TATICPROCEDURE ''SomeProcedureName''( ''Param1'' ''ParamsN'')
INIT PROCEDURE ''SomeProcedureName''
EXIT PROCEDURE ''SomeProcedureName''
TATICFUNCTION ''SomeProcedureName''
TATICFUNCTION ''SomeProcedureName''()
TATICFUNCTION ''SomeProcedureName''( ''Param1'' ''ParamsN'')
Procedures and functions in Harbour can be specified with the keywords PROCEDURE
, or FUNCTION
. Naming rules are the same as those for ''Variables'' (up to 63 characters non-case sensitive). Both Procedures and Functions may be qualified by the scope qualifier ''STATIC'' to restrict their usage to the scope of the module where defined.
The ''INIT'' or ''EXIT'' optional qualifiers, will flag the procedure to be automatically invoked just before calling the application startup procedure, or just after quitting the application, respectively. Parameter
A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
s passed to a procedure/function appear in the subroutine as local variables, and may accept any type, including references.
Changes to argument variables are not reflected in respective variables passed by the calling procedure/function/method unless explicitly passed BY REFERENCE using the ''@'' prefix.
PROCEDURE has no return value, and if used in an Expression context will produce a ''NIL'' value.
FUNCTION may return any type by means of the RETURN statement, anywhere in the body of its definition.
An example procedure definition and a function call follows:
x := Cube( 2 )
FUNCTION Cube( n )
RETURN n ** 3
Sample code
The typical "hello world
Hello World may refer to:
* "Hello, World!" program, a computer program that outputs or displays the message "Hello, World!"
Music
* "Hello World!" (composition), song by the Iamus computer
* "Hello World" (Tremeloes song), 1969
* "Hello World" ...
" program would be:
? "Hello, world!"
Or:
QOut( "Hello, world!" )
Or:
Alert( "Hello, world!" )
Or, enclosed in an explicit procedure:
PROCEDURE Main()
? "Hello, world!"
RETURN
OOP examples
Main procedure:
#include "hbclass.ch"
PROCEDURE Main()
LOCAL oPerson
CLS
oPerson := Person():New( "Dave" )
oPerson:Eyes := "Invalid"
oPerson:Eyes := "Blue"
Alert( oPerson:Describe() )
RETURN
Class definition:
CREATE CLASS Person
VAR Name INIT ""
METHOD New( cName )
METHOD Describe()
ACCESS Eyes INLINE ::pvtEyes
ASSIGN Eyes( x ) INLINE iif( HB_ISSTRING( x ) .AND. x $ "Blue,Brown,Green", ::pvtEyes := x, Alert( "Invalid value" ) )
PROTECTED:
VAR pvtEyes
ENDCLASS
// Sample of normal Method definition
METHOD New( cName ) CLASS Person
::Name := cName
RETURN Self
METHOD Describe() CLASS Person
LOCAL cDescription
IF Empty( ::Name )
cDescription := "I have no name yet."
ELSE
cDescription := "My name is: " + ::Name + ";"
ENDIF
IF ! Empty( ::Eyes )
cDescription += "my eyes' color is: " + ::Eyes
ENDIF
RETURN cDescription
Tools
* hbmk2 – Build tool like make
* hbrun – Shell interpreter for Harbour. Macro compiling allows to run any valid Harbour code as it's being compiled
* hbformat – Formats source code written on Harbour or another dialect according to defined rules
* hbpp – Pre-processor, a powerful tool which avoids typical problems found on C language per-processor
* hbi18n – Tools to localizing text on applications
* hbdoc – Creates documentation for Harbour
All tools are multi-platform.
Development
Today Harbour development is led by Viktor Szakáts in collaboration with Przemysław Czerpak who also contributes many components of the core language and supplementary components. HBIDE and some other components, especially HBQt, are developed by Pritpal Bedi. Other members of the development community send changes to the GitHub
GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...
source repository.
As of 2015 Harbour development is active and vibrant.
xHarbour comparison
xHarbour is a fork of the earlier Harbour project. xHarbour takes a more aggressive approach to implementing new features in the language, while Harbour is more conservative in its approach, aiming first of all for an exact replication of Clipper behaviour and then implementing new features and extensions as a secondary consideration. It should also be noted that Harbour is supported on a wide variety of operating systems
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
while xHarbour only really supports MS Windows and Linux 32-bit.
The Harbour developers have attempted to document all hidden behaviour in the Clipper language and test Harbour-compiled code alongside the same code compiled with Clipper to maintain compatibility.
The Harbour developers explicitly reject extensions to the language where those extensions would break Clipper compatibility. These rejections were softened recently since the new Harbour architecture allows extensions out of the core compiler.
A detailed comparison between extensions implemented in Harbour and xHarbour can be found in the source repository of the project on GitHub.
GUI libraries and tools
*
hbide
' – Integrated Development Environment
An integrated development environment (IDE) is a Application software, software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, an ...
to help Harbour development and various xBase dialects
*
PTSource IDE
' – Integrated Development Environment
An integrated development environment (IDE) is a Application software, software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, an ...
includes Harbour
*
HwGui
' – Open Source cross-platform GUI library for Harbour
*
HMG
' – Free, Open Source xBase Win32
The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running. Programs can acces ...
/ GUI Development System for Harbour
*
MiniGUI
' – Free / Open Source xBase Win32 / GUI Development System (a Fork (software development)
In software development, a fork is a codebase that is created by duplicating an existing codebase and, generally, is subsequently modified independently of the original. Software built from a fork initially has identical behavior as software ...
of both HMG and Harbour)
*
ooHG
' – Object Oriented Harbour GUI – a fork "class based and oop programming" of HMG
*
Marinas-GUI
' – Multi-Platform QT Based GUI Development Package for Harbour. Marinas-GUI downloads as a complete installation package for the chosen target platform (IDE, Version Control, Harbour/C Compiler, Libraries etc.) – Basically install and start coding and compiling
See also
* Visual FoxPro
Visual FoxPro is a programming language that was developed by Microsoft. It is a data-centric and procedural programming language with object-oriented programming (OOP) features.
It was derived from FoxPro (which was itself descended from FoxB ...
* Visual Objects
* XBase++
* PWCT free open source visual programming language support Harbour through HarbourPWCT
References
External links
*
The Oasis
Clipper, FoxPro and Xbase++ community repository
HBIDE
Harbour Developers Mailing List
Harbour Users Mailing List
* , Harbour Dictionary of Functions Wiki
{{DEFAULTSORT:Harbour (Software)
Procedural programming languages
XBase programming language family
Fourth-generation programming languages
Dynamic programming languages
Dynamically typed programming languages
Query languages
Declarative programming languages
DOS software
Linux programming tools
Programming tools for Windows
Windows database-related software
Programming languages created in 1999
1999 software
High-level programming languages
Free software programmed in C
Multi-paradigm programming languages
Table-oriented programming
Articles with example code