History
The idea of a free software Clipper compiler had been floating around for a long time and the subject has often cropped up 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 aDatabase support
Harbour extends the Clipper Replaceable Database Drivers (RDD) approach. It offers multiple RDDs such as DBF, DBFNTX, DBFCDX, DBFDBT and DBFFPT. In Harbour multiple RDDs can be used in a single application, and new logical RDDs can be defined by combining other RDDs. The RDD architecture allows for inheritance, so that a given RDD may extend the functionality of other existing RDD(s). Third-party RDDs, like RDDSQL, RDDSIX, RMDBFCDX, Advantage Database Server, and Mediator exemplify some of the RDD architecture features. DBFNTX implementation has almost same functionality of DBFCDX and RDDSIX. NETIO and LetoDB provide remote access over TCP protocol. Harbour also offersProgramming philosophy
Unlike Java which is intended to be write once, run anywhere, Harbour aims to be write once, compile anywhere. As the same compiler is available for all of the above operating systems, there is no need for recoding to produce identical products for different platforms, except when operating system dependent features are used. Cross-compiling is supported withMacro Operator (runtime compiler)
One of the most powerful features of xBase languages is theObject 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 aSyntax and semantics
Built-in data types
Harbour has six scalar types : Nil, String, Date,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. 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, can be accessed and modified by means of runtime macros, and can be accessed and modified 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 includes the core database engine, a query system, a forms engine, and a programming langua ...
, and Clipper
A clipper was a type of mid-19th-century merchant sailing vessel, designed for speed. Clippers were generally narrow for their length, small by later 19th century standards, could carry limited bulk freight, and had a large total sail area. "Cl ...
control structures as well as additional ones inspired by the C or Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
programming languages:
Loops
OWHILE ''ConditionExp''
''...''
OOP
OOP, Oop, or oop may refer to:
Science and technology
* Object-oriented positioning
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of ...
XIT XIT may refer to:
*XIT (band), a Native American rock group
* XIT, a name briefly used by the 1960s English pop group Consortium
*XIT Ranch
The XIT Ranch was a cattle ranch in the Texas Panhandle which operated from 1885 to 1912. Comprising over ...
END O
FOR ''Var'' := ''InitExp'' TO ''EndExp'' TEP ''StepExp'' Tep may refer to:
*Tep language
*Tepecano language (ISO 639:tep)
People
''Tep'' is a common Cambodian name.
*Tep Rindaro
*Tep Vanny
*Tep Vong
*Tep Boprek
*Tep Sothy
*Tep Ngorn
Other
*Tep Pranam temple
*Tep Wireless
*''Tep Songva'', film
*''Tep S ...
''...''
OOP
OOP, Oop, or oop may refer to:
Science and technology
* Object-oriented positioning
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of ...
XIT XIT may refer to:
*XIT (band), a Native American rock group
* XIT, a name briefly used by the 1960s English pop group Consortium
*XIT Ranch
The XIT Ranch was a cattle ranch in the Texas Panhandle which operated from 1885 to 1912. Comprising over ...
NEXT
FOR EACH ''Var'' IN ''CollectionExp''
''...''
'Var'':__enumIndex() OOP
OOP, Oop, or oop may refer to:
Science and technology
* Object-oriented positioning
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of ...
XIT XIT may refer to:
*XIT (band), a Native American rock group
* XIT, a name briefly used by the 1960s English pop group Consortium
*XIT Ranch
The XIT Ranch was a cattle ranch in the Texas Panhandle which operated from 1885 to 1912. Comprising over ...
NEXT
* The ''...'' is a sequence of one of 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 XIT may refer to:
*XIT (band), a Native American rock group
* XIT, a name briefly used by the 1960s English pop group Consortium
*XIT Ranch
The XIT Ranch was a cattle ranch in the Texas Panhandle which operated from 1885 to 1912. Comprising over ...
ASE ''LiteralExp'' ''...''
XIT XIT may refer to:
*XIT (band), a Native American rock group
* XIT, a name briefly used by the 1960s English pop group Consortium
*XIT Ranch
The XIT Ranch was a cattle ranch in the Texas Panhandle which operated from 1885 to 1912. Comprising over ...
THERWISE ''...''
ENDWITCH
Witchcraft traditionally means the use of magic or supernatural powers to harm others. A practitioner is a witch. In medieval and early modern Europe, where the term originated, accused witches were usually women who were believed to have u ...
* 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 handing.
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/Functions
TATIC Tat language may refer to the following:
* Tat language (Caucasus) in Dagestan and Azerbaijan, a southwestern Iranian language, closely related to Persian
* Tati (Iran), a group of Northwestern Iranian dialects, including Takestani, closely related ...
PROCEDURE ''SomeProcedureName''
TATIC Tat language may refer to the following:
* Tat language (Caucasus) in Dagestan and Azerbaijan, a southwestern Iranian language, closely related to Persian
* Tati (Iran), a group of Northwestern Iranian dialects, including Takestani, closely related ...
PROCEDURE ''SomeProcedureName''()
TATIC Tat language may refer to the following:
* Tat language (Caucasus) in Dagestan and Azerbaijan, a southwestern Iranian language, closely related to Persian
* Tati (Iran), a group of Northwestern Iranian dialects, including Takestani, closely related ...
PROCEDURE ''SomeProcedureName''( ''Param1'' ''ParamsN'')
INIT PROCEDURE ''SomeProcedureName''
EXIT PROCEDURE ''SomeProcedureName''
TATIC Tat language may refer to the following:
* Tat language (Caucasus) in Dagestan and Azerbaijan, a southwestern Iranian language, closely related to Persian
* Tati (Iran), a group of Northwestern Iranian dialects, including Takestani, closely related ...
FUNCTION ''SomeProcedureName''
TATIC Tat language may refer to the following:
* Tat language (Caucasus) in Dagestan and Azerbaijan, a southwestern Iranian language, closely related to Persian
* Tati (Iran), a group of Northwestern Iranian dialects, including Takestani, closely related ...
FUNCTION ''SomeProcedureName''()
TATIC Tat language may refer to the following:
* Tat language (Caucasus) in Dagestan and Azerbaijan, a southwestern Iranian language, closely related to Persian
* Tati (Iran), a group of Northwestern Iranian dialects, including Takestani, closely related ...
FUNCTION ''SomeProcedureName''( ''Param1'' ''ParamsN'')
Procedures/ Functions in Harbour can be specified with the keywords PROCEDURE
, or FUNCTION
. Naming rules are 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 have 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'' is a salutation or greeting in the English language. It is first attested in writing from 1826. Early uses
''Hello'', with that spelling, was used in publications in the U.S. as early as the 18 October 1826 edition of the '' Norwich ...
" 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 pre-processor
* hbi18n – Tools to localizing text on applications
* hbdoc – Creates documentation for Harbour
All tools are multiplatform.
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, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, co ...
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, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
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 software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools a ...
to help Harbour development and various xBase dialects
* '
PTSource IDE
'' – Integrated Development Environment
An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools a ...
includes Harbour
* '
HwGui
'' – Open Source cross-platform GUI library for Harbour
* '
HMG
'' – Free / Open Source xBase Win32
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations ...
/ GUI Development System for Harbour
* '
MiniGUI
'' – Free / Open Source xBase Win32 / GUI Development System (a Fork (software development)
In software engineering, a project fork happens when developers take a copy of source code from one software package and start independent development on it, creating a distinct and separate piece of software. The term often implies not merely a ...
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 Microsoft data-centric procedural programming language with object-oriented programming (OOP) features.
It was derived from FoxPro (originally known as FoxBASE) which was developed by Fox Software beginning in 1984. Fox Techno ...
* 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 Wiki (Harbour Functions Dictionary)
{{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