xHarbour Language Extensions

xHarbour is a fork from Harbour created December 2001. It aims to
follow a more aggressive development path, and be more responsive to
market trends, and users input.

As it stands at this point, xHarbour offers many Syntax extensions over
Harbour and the Clipper language in general, including:

Associative Arrays:

Associative Arrays are like LITE Objects. Properties may be added on the
fly without any declaration, much like new PRIVATE or PUBLIC can be
created by simply assigning a value.
Associative Arrays, may use Objects Syntax (':' operator) or Array Index
Syntax ('[]' operator) with the Property Name as the INDEX.
New Property will automatically be created upon first assignment.

Hashes

In the past, clipper (and then xharbour) users felt the need to have
what is called "hash" or "associative array" and that is nowadays
provided at language level by all the most modern languages: Perl, PHP,
Python, Ruby, name it. An associative array is an array that bounds a
value (that can be of any variable type allowed by the language) to a
key (that may be of any "orderable" or "distinguishable" variable) in a
1:1 relationship.

An extension has been recently added to add the HASH type as one of the
basic xHarbour type. In other words, hashes are now a rightful type of
xHarbour. They are individuated by the "H" variable type.

Hashes, like arrays, can be managed with both a specific API and by
language constructs.

SWITCH syntax:

NOTE: This syntax is modeled after the C 'switch' flow control. It
offers great speed benefit [30-300%] over DO CASE flow control, but is
restricted to comparing only constants. Constants maybe: Integers,
Longs, or Single Character Strings [much like in C]

WARNING: Those NOT familiar with the C switch flow control, should
understand that unlike DO CASE, you MUST explicitly use the EXIT
statement or else logic will FALL THROUGH to the NEXT CASE, until
stopped at a BREAK, or END statements.
At first this might seem VERY ODD, but it provides great flexibility
exactly like the C model.
See tests/switch.prg to for a sample and to learn how the FALL-THROUGH
logic works.

Multi Threading (MT) Support:

xHarbour supports MT applications. There is still some more work to be
done, but you can already take advantage of this very powerful feature.
Basic sample can be found at tests/mttest.prg

Syntax:
StartThread( @MyThreadFunc() [, xParam1 [,xParamN ] ] )

NOTE: MT Application must link against the MT versions of the Libraries,
i.e. vmmt.lib, rtlmt.lib, ppmt.lib, rddmt.lib, dbfntxmt.lib and
dbfcdxmt.lib. The full description of MT is beyond the scope of this
document.

Portable Sockets Support

The full description is beyond the scope of this document - please refer
to samples/sitesvr/sitesvr.prg for a Web Server example.

Perl-5 compatible RegEx

xHarbour includes PCRE which is a full feature, Perl 5 compatible,
Regular
Expression engine. Full feature Search & Replace classes are currently
under
construction, but you may already use the full power of RegEx searches,
new operators, HAS and LIKE.

cExp HAS cPatern|CompiledRegEx => bFoundThe HAS operator scans cExp for a any match of the supplied cRegEx
or CompiledRegEx, and returns .T. if found, .F. otherwise.

cExp LIKE cPatern|CompiledRegEx => bLikeThe LIKE operator returns .T. if the *complete* cExp is a match, to
the supplied cRegEx or CompiledRegEx, .F. otherwise.

TRY syntax

The above is very similar to Clipper BEGIN SEQ, BREAK(), RECOVER USING,
END, but is more inline with more "modern" languages, and dismisses the
need to worry about Error codeblock.

IN operator

<Exp> IN <Array_or_StringExp> => .T./.F.

The IN operator is very similar to the $ operator, but is valid on
*both* Strings and Arrays. IN is much faster than the equivalent:
aScan( <Array>, <Exp> ) > 0

Variable Parameters syntax

Function <cFuncName>( ... )

The above definition allows this Function to receive up-to 254
parameters. You may retrieve an ARRAY with all the parameters using:
HB_aParams()

The above is appropriate for such functions that may receive any number
of generic parameters, which normally will then be processed in a loop,
or with hard coded IF statements based on PCount(). Instead the above is
much easier to code, requires less memory, and is faster than declaring
the parameters.

GLOBAL variables:

GLOBAL <Id1> [,<Id2> [,<IdN>]]

GLOBAL Variables are a new kind of a declared variables. they have
PUBLIC like visibility, but are faster than even STATICs. GLOBALS can be
referenced from other modules using the syntax:
GLOBAL EXTERNAL <Id1> [,<Id2> [,<IdN>]]

GLOBAL Variables have the added benefit of being *directly* accessible
from C code too.