Harbour Reference Guide - API

API

Application

DO()

Calls a procedure or a function
Syntax
DO( <xFuncProc> [, <xArguments...>] ) --> <xRetVal>
Argument(s)
<xFuncProc> = Either a string with a function/procedure name to be called or a codeblock to evaluate.
<xArguments> = arguments passed to a called function/procedure or to a codeblock.
Returns
<xRetVal> A value that was returned from called function.
Description
This function can be called either by the harbour compiler or by user. The compiler always passes the item of IT_SYMBOL type that stores the name of procedure specified in DO <proc> WITH ... statement.
If called procedure/function doesn't exist then a runtime error is generated.
This function can be used as replacement of macro operator. It is also used internally to implement DO <proc> WITH <args...> In this case <xFuncProc> is of type HB_SYMB.
Example(s)
cbCode ={|x| MyFunc( x )}
DO( cbCode, 1 )
cFunction := "MyFunc"
xRetVal := DO( cFunction, 2 )
// Old style (slower):
DO &cFunction WITH 3
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
Index
API

HB_PVALUE()

Retrieves the value of an argument.
Syntax
HB_PVALUE( <nArg> ) --> <xExp>
Argument(s)
A number that indicates the argument to check.
Returns
<xExp> Returns the value stored by an argument.
Description
This function is useful to check the value stored in an argument.
Example(s)
See Test
Test(s)
function Test( nValue, cString )
if PCount() == 2
? hb_PValue( 1 ), nValue
? hb_PValue( 2 ), cString
endif
return nil
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
See also
PCOUNT()
Index
API

PCOUNT()

Retrieves the number of arguments passed to a function.
Syntax
PCOUNT() --> <nArgs>
Argument(s)
None
Returns
<nArgs> A number that indicates the number of arguments passed to a function or procedure.
Description
This function is useful to check if a function or procedure has received the required number of arguments.
Example(s)
See Test
Test(s)
function Test( xExp )
if PCount() == 0
? "This function needs a parameter"
else
? xExp
endif
return nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
HB_PVALUE()
Index
API

PROCFILE()

This function allways returns an empty string.
Syntax
PROCFILE( <xExp> ) --> <cEmptyString>
Argument(s)
<xExp> is any valid type.
Returns
<cEmptyString> Return an empty string
Description
This function is added to the RTL for full compatibility. It always returns an empty string.
Example(s)
? ProcFile()
Test(s)
function Test()
? ProcFile()
? ProcFile( NIL )
? ProcFile( 2 )
return nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
PROCNAME(),PROCLINE()
Index
API

PROCLINE()

Gets the line number of the current function on the stack.
Syntax
PROCLINE( <nLevel> ) --> <nLine>
Argument(s)
<nLevel> is the function level required.
Returns
<nLine> The line number of the function that it is being executed.
Description
This function looks at the top of the stack and gets the current line number of the executed function if no arguments are passed. Otherwise it returns the line number of the function or procedure at <nLevel>.
Example(s)
See Test
Test(s)
function Test()
? ProcLine( 0 )
? ProcName( 2 )
return nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
PROCNAME(),PROCFILE()
Index
API

PROCNAME()

Gets the name of the current function on the stack
Syntax
PROCNAME( <nLevel> ) --> <cProcName>
Argument(s)
<nLevel> is the function level required.
Returns
<cProcName> The name of the function that it is being executed.
Description
This function looks at the top of the stack and gets the current executed function if no arguments are passed. Otherwise it returns the name of the function or procedure at <nLevel>.
Example(s)
See Test
Test(s)
This test will show the functions and procedures in stack.
before executing it.
function Test()
LOCAL n := 1
while !Empty( ProcName( n ) )
? ProcName( n++ )
end do
return nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
PROCLINE(),PROCFILE()
Index
API

Array

AADD()

Dynamically add an element to an array
Syntax
AADD(<aArray>[, <xValue>]) --> Value
Argument(s)
<aArray> The name of an array
<xValue> Element to add to array <aArray>
Returns
<Value> if specified <xValue>, <xValue> will return , otherwise this function returns a NIL value.
Description
This function dynamically increases the length of the array named <aArray> by one element and stores the value of <xValue> to that newly created element.
<xValue> may be an array reference pointer, which in turn may be stored to an array's subscript position.
Example(s)
LOCAL aArray:={}
LOCAL x
AADD(aArray,10)
FOR x:=1 to 10
AADD(aArray,x)
NEXT
// Result is: { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
AINS(),ASIZE()
Index
API

ACLONE()

Duplicate a multidimensional array
Syntax
ACLONE(<aSource>) --> aDuplicate
Argument(s)
<aSource> Name of the array to be cloned.
Returns
<aDuplicate> A new array pointer reference complete with nested array values.
Description
This function makes a complete copy of the array expressed as <aSource> and return a cloned set of array values. This provides a complete set of arrays values for all dimensions within the original array <aSource>
Example(s)
LOCAL aOne, aTwo
aOne := {"Harbour"," is ","POWER"}
aTwo := ACLONE(aOne)       // Result: aTwo is {"Harbour"," is ","POWER"}
aOne[1] := "The Harbour Compiler"
// Result:
// aOne is {"The Harbour Compiler"," is ","POWER"}
// aTwo is {"Harbour"," is ","POWER"}
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'CA-Cl*pper will return NIL if the parameter is not an array.'
File(s)
Library is vm
See also
ACOPY(),ADEL(),AINS(),ASIZE()
Index
API

ACOPY()

Copy elements from one array to another
Syntax
ACOPY( <aSource>, <aTarget>, [<nStart>], [<nCount>], [<nTargetPos>] ) --> aTarget
Argument(s)
<aSource> is the array to copy elements from.
<aTarget> is the array to copy elements to.
<nStart> is the beginning subscript position to copy from <aSource>
<nCount> the number of subscript elements to copy from <aSource>.
<nTargetPos> the starting subscript position in <aTarget> to copy elements to.
Returns
<aTarget> an array pointer reference
Description
This function copies array elements from <aSource> to <aTarget>.
<nStart> is the beginning element to be copied from <aSource>; the default is 1.
<nCount> is the number of elements to be copied from <aSource>; the default is the entire array.
<nTargetPos> is the subscript number in the target array,<aTarget>,
to which array elements are to be copied; the default is 1
This function will copy all data types in <aSource> to <aTarget>.
If an array element in <aSource> is a pointer reference to another array, that array pointer will be copied to <aTarget>; not all subdimensions will be copied from one array to the next. This must be accomplished via the ACLONE() function.
Note: If array <aSource> is larger then <aTarget>, array elements will start copying at <nTargetPos> and continue copying until the end of array <aTarget> is reached. The ACOPY() function doesn't append subscript positions to the target array, the size of the target array <aTarget> remains constant.
Example(s)
LOCAL nCount := 2, nStart := 1, aOne, aTwo
aOne := {"HARBOUR"," is ","POWER"}
aTwo := {"CLIPPER"," was ","POWER"}
ACOPY(aOne, aTwo, nStart, nCount)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
ACLONE(),ADEL(),AEVAL(),AFILL(),AINS(),ASORT()
Index
API

ADEL()

Delete an element form an array.
Syntax
ADEL(<aArray>, <nPos>) --> aTarget
Argument(s)
<aArray> Name of array from which an element is to be removed.
<nPos> Subscript of the element to be removed.
Returns
<aTarget> an array pointer reference.
Description
This function deletes the element found at <nPos> subscript position in the array <aArray>. All elements in the array <aArray> below the given subscript position <nPos> will move up one position in the array. In other words, what was formerly the sixth subscript position will become the fifth subscript position. The length of the array <aArray> will remain unchanged,as the last element in the array will become a NIL data type.
Example(s)
LOCAL aArray
aArray := {"Harbour", "is", "Power"}
ADEL(aArray, 2) // Result: aArray is {"Harbour", "Power"}
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
ACOPY(),AINS(),AFILL()
Index
API

AEVAL()

Evaluates the subscript element of an array
Syntax
AEVAL(<aArray>, <bBlock>, [<nStart>], [<nCount>]) --> aArray
Argument(s)
<aArray> Is the array to be evaluated.
<bBlock> Is a code block to evaluate for each element processed.
<nStart> The beginning array element index to evaluate.
<nCount> The number of elements to process.
Returns
<aArray> an array pointer reference.
Description
This function will evaluate and process the subscript elements in <aArray>. A code block passed as <bBlock> defines the operation to be executed on each element of the array. All elements in <aArray> will be evaluated unless specified by a beginning subscript position in <nStart> for <nCount> elements.
Two parameters are passed to the code block <bBlock>. The individual elements in an array are the first parameter and the subscript position is the second.
AEVAL() does not replace a FOR...NEXT loop for processing arrays. If an array is an autonomous unit, AEVAL() is appropriate. If the array is to be altered or if elements are to be reevaluated, a FOR...NEXT loop is more appropriate.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
EVAL(),DBEVAL()
Index
API

AFILL()

Fill an array with a specified value
Syntax
AFILL( <aArray>, <xValue>, [<nStart>], [<nCount>] ) --> aTarget
Argument(s)
<aArray> Name of array to be filled.
<xValue> Expression to be globally filled in <aArray>
<nStart> Subscript starting position
<nCount> Number of subscript to be filled
Returns
<aTarget> an array pointer.
Description
This function will fill each element of an array named <aArray> with the value <xValue>. If specified, <nStart> denotes the beginning element to be filled and the array elements will continue to be filled for <nCount> positions. If Not specified, the value of <nStart> will be 1, and the value of <nCount> will be the value of LEN(<aArray>); thus, all subscript positions in the array <aArray> will be filled with the value of <xValue>.
This function will work on only a single dimension of <aArray>. If there are array pointer references within a subscript <aArray>, those values will be lost, since this function will overwrite those values with new values.
Example(s)
LOCAL aTest:={Nil,0,1,2}
Afill(aTest,5)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
AADD(),AEVAL(),DBSTRUCT(),DIRECTORY()
Index
API

AINS()

Insert a NIL value at an array subscript position.
Syntax
AINS( <aArray>, <nPos> ) --> aTarget
Argument(s)
<aArray> Array name.
<nPos> Subscript position in <aArray>
Returns
<aTarget> an array pointer reference.
Description
This function inserts a NIL value in the array named <aArray> at the <nPos>th position.
All array elements starting with the <nPos>th position will be shifted down one subscript position in the array list and the last item in the array will be removed completely. In other words, if an array element were to be inserted at the fifth subscript position, the element previously in the fifth position would now be located at the sixth position. The length of the array <aArray> will remain unchanged.
Example(s)
LOCAL aArray:={"Harbour","is","Power!","!!!"}
AINS(aArray,4)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
AADD(),ACOPY(),ADEL(),AEVAL(),AFILL(),ASIZE()
Index
API

ARRAY()

Create an uninitialized array of specified length
Syntax
ARRAY( <nElements> [, <nElements>...] ) --> aArray
Argument(s)
<nElements> is the number of elements in the specified dimension.
Returns
<aArray> an array of specified dimensions.
Description
This function returns an uninitialized array with the length of <nElements>.
Nested arrays are uninitialized within the same array pointer reference if additional parameters are specified.
Establishing a memory variable with the same name as the array may destroy the original array and release the entire contents of the array. This depends, of course, on the data storage type of either the array or the variable with the same name as the array.
Example(s)
PROCEDURE Main()
LOCAL aArray:=Array(10)
LOCAL x
FOR x:=1 to LEN(aArray)
aArray[x]:=Array(x)
NEXT
// Result is: { { NIL }, { NIL, NIL }, ... }
RETURN
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant except that arrays in Harbour can have an unlimited number of elements
File(s)
Library is vm
See also
AADD(),ADEL(),AFILL(),AINS()
Index
API

ASCAN()

Scan array elements for a specified condition
Syntax
ASCAN( <aTarget>, <xSearch>, [<nStart>], [<nCount>] ) --> nStoppedAt
Argument(s)
<aTarget> Array to be scanned.
<xSearch> Expression to search for in <aTarget>
<nStart> Beginning subscript position at which to start the search.
<nCount> Number of elements to scan with <aTarget>.
Returns
<nStoppedAt> A numeric value of subscript position where <xSearch> was found, or 0 if <xSearch> is not found.
Description
This function scan the content of array named <aTarget> for the value of <xSearch>. The return value is the position in the array <aTarget> in which <xSearch> was found. If it was not found, the return value will be 0.
If specified, the beginning subscript position at which to start scanning may be set with the value passed as <nStart>. The default is 1.
If specified, the number of array elements to scan may be set with the value passed as <nCount>. The default is the number of elements in the array <aTarget>.
If <xSearch> is a code block, the operation of the function is slightly different. Each array subscript pointer reference is passed to the code block to be evaluated. The scanning routine will continue until the value obtained from the code block is a logical true (.T.) or until the end of the array has been reached.
Example(s)
aDir:=Directory("*.prg")
AScan(aDir,,,{|x,y| x[1]="Test.prg"})
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is not CA-Cl*pper compatible. CA-Cl*pper ASCAN() is affected by the SET EXACT ON/OFF Condition'
File(s)
Library is vm
See also
AEVAL()
Index
API

ASIZE()

Adjust the size of an array
Syntax
ASIZE(<aArray>, <nLen>) --> aTarget
Argument(s)
<aArray> Name of array to be dynamically altered
<nLen> Numeric value representing the new size of <aArray>
Returns
<aTarget> an array pointer reference to <aTarget>.
Description
This function will dynamically increase or decrease the size of <aArray> by adjusting the length of the array to <nLen> subscript positions.
If the length of the array <aArray> is shortened, those former subscript positions are lost. If the length of the array is lengthened a NIL value is assigned to the new subscript position.
Example(s)
aArray := { 1 }          // Result: aArray is { 1 }
ASIZE(aArray, 3)         // Result: aArray is { 1, NIL, NIL }
ASIZE(aArray, 1)         // Result: aArray is { 1 }
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'If HB_COMPAT_C53 is defined, the function generates an Error, else it will return the array itself.'
File(s)
Library is vm
See also
AADD(),ADEL(),AFILL(),AINS()
Index
API

ASORT()

Sort an array
Syntax
ASORT( <aArray>, [<nStart>], [<nCount>], [<bSort>] ) --> aArray
Argument(s)
<aArray> Array to be sorted.
<nStart> The first element to start the sort from, default is 1.
<nCount> Number of elements starting from <nStart> to sort, default is all elements.
<bSort> Code block for sorting order, default is ascending order {| x, y | x < y }. The code block should accept two parameters and must return .T. if the sort is in order, .F. if not.
Returns
<aArray> reference to the now sorted <aArray> or NIL if the passed <aArray> is not an array.
Description
ASORT() sort all or part of a given array. If <bSort> is omitted, the function expect <aArray> to be one dimensional array containing single data type (one of: Character, Date, Logical, Numeric) and sort this array in ascending order: Character are sorted by their ASCII value, Dates are sorted chronologically, Logical put .F. values before .T., Numeric are sorted by their value.
If <bSort> is specified, it is used to handle the sorting order. With each time the block is evaluate, two array elements are passed to the code block, and <bSort> must return a logical value that state if those elements are in order (.T.) or not (.F.). Using this block you can sort multidimensional array, descending orders or even (but why would you want to do that) sort array that contain different data type.
Example(s)
// sort numeric values in ascending order
ASORT( { 3, 1, 4, 42, 5, 9 } )     // result: { 1, 3, 4, 5, 9, 42 }
// sort character strings in descending lexical order
aKeys := { "Ctrl", "Alt", "Delete" }
bSort := {| x, y | UPPER( x ) > UPPER( y ) }
ASORT( aKeys,,, bSort )      // result: { "Delete", "Ctrl", "Alt" }
// sort two-dimensional array according to 2nd element of each pair
aPair :=   { {"Sun",8}, {"Mon",1}, {"Tue",57}, {"Wed",-6} }
ASORT( aPair,,, {| x, y | x[2] < y[2] } )
// result: { {"Wed",-6}, {"Mon",1}, {"Sun",8}, {"Tue",57} }
Status
Ready
Compliance
Codeblock calling frequency and order differs from CA-Cl*pper, since Harbour uses a different (faster) sorting algorithm (quicksort)
File(s)
Library is vm
See also
ASCAN(),EVAL(),SORT
Index
API

ATAIL()

Returns the rightmost element of an array
Syntax
ATAIL( <aArray> ) --> Element
Argument(s)
<aArray> is the array.
Returns
<Element> the expression of the last element in the array.
Description
This function return the value of the last element in the array named <aArray>. This function does not alter the size of the array or any of the subscript values.
Example(s)
LOCAL array:= {"Harbour", "is", "Supreme", "Power"}
? ATAIL(aArray) // Result is "Power"
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
LEN(),ARRAY(),ASIZE(),AADD()
Index
API

Classes

HBClass()

HBClass() is used in the creation of all classes
Syntax
oClass := HBClass():New("TMyClass")
-or-
HBClass() is usually accessed by defining a class with the commands defined in hbclass.h:
CLASS HBGetList // Calls HBClass() to create the HBGetList class
...
ENDCLASS
Returns
An instance of the HBClass Class. This special object's :New() method can then create the classes you define.
Description
HBClass is a class that ... The class methods are as follows:
New() Create a new instance of the class
Example(s)
FUNCTION TestObject()
local oObject
oObject := HBClass():New("TMyClass")
oObject:End()
RETURN Nil
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'Object Oriented syntax in Harbour is compatible with CA-Cl*pper.
However CA-Cl*pper only allowed creation of objects from a few standard classes, and did not let the programmer create new classes.
In Harbour, you can create your own classes--complete with Methods, Instance Variables, Class Variables and Inheritance. Entire applications can be designed and coded in Object Oriented style.'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
__objHasData(),Object Oriented Programming,CLASS
Index
API

Conversion

BIN2I()

Convert signed short encoded bytes into Harbour numeric
Syntax
BIN2I( <cBuffer> ) --> nNumber
Argument(s)
<cBuffer> is a character string that contain 16 bit encoded signed short integer (least significant byte first). The first two bytes are taken into account, the rest if any are ignored.
Returns
BIN2I() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2I() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2I() take two bytes of encoded 16 bit signed short integer and convert it into standard Harbour numeric value.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
BIN2I() is the opposite of I2BIN()
Example(s)
// Show DBF last update date
FUNCTION main()
LOCAL nHandle, cYear, cMonth, cDay
nHandle := fopen( "test.dbf" )
IF nHandle > 0
fseek( nHandle, 1 )
cYear := cMonth := cDay := " "
fread( nHandle, @cYear , 1 )
fread( nHandle, @cMonth, 1 )
fread( nHandle, @cDay  , 1 )
? "Last update:", BIN2I( cYear ), BIN2I( cMonth ), BIN2I( cDay )
fclose( nHandle )
ELSE
? "Can not open file"
ENDIF
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
BIN2L(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
Index
API

BIN2L()

Convert signed long encoded bytes into Harbour numeric
Syntax
BIN2L( <cBuffer> ) --> nNumber
Argument(s)
<cBuffer> is a character string that contain 32 bit encoded signed long integer (least significant byte first). The first four bytes are taken into account, the rest if any are ignored.
Returns
BIN2L() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2L() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2L() take four bytes of encoded 32 bit signed long integer and convert it into standard Harbour numeric value.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
BIN2L() is the opposite of L2BIN()
Example(s)
// Show number of records in DBF
FUNCTION main()
LOCAL nHandle, cBuffer := space( 4 )
nHandle := fopen( "test.dbf" )
IF nHandle > 0
fseek( nHandle, 4 )
fread( nHandle, @cBuffer, 4 )
? "Number of records in file:", BIN2L( cBuffer )
fclose( nHandle )
ELSE
? "Can not open file"
ENDIF
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
BIN2I(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
Index
API

BIN2U()

Convert unsigned long encoded bytes into Harbour numeric
Syntax
BIN2U( <cBuffer> ) --> nNumber
Argument(s)
<cBuffer> is a character string that contain 32 bit encoded unsigned long integer (least significant byte first). The first four bytes are taken into account, the rest if any are ignored.
Returns
BIN2U() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2U() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2U() take four bytes of encoded 32 bit unsigned long integer and convert it into standard Harbour numeric value.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
BIN2U() is the opposite of U2BIN()
Example(s)
// Show number of records in DBF
FUNCTION main()
LOCAL nHandle, cBuffer := space( 4 )
nHandle := fopen( "test.dbf" )
IF nHandle > 0
fseek( nHandle, 4 )
fread( nHandle, @cBuffer, 4 )
? "Number of records in file:", BIN2U( cBuffer )
fclose( nHandle )
ELSE
? "Can not open file"
ENDIF
RETURN NIL
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'XPP'
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
Index
API

BIN2W()

Convert unsigned short encoded bytes into Harbour numeric
Syntax
BIN2W( <cBuffer> ) --> nNumber
Argument(s)
<cBuffer> is a character string that contain 16 bit encoded unsigned short integer (least significant byte first). The first two bytes are taken into account, the rest if any are ignored.
Returns
BIN2W() return numeric integer (or 0 if <cBuffer> is not a string).
Description
BIN2W() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. BIN2W() take two bytes of encoded 16 bit unsigned short integer and convert it into standard Harbour numeric value.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
BIN2W() is the opposite of W2BIN()
Example(s)
// Show header length of a DBF
FUNCTION main()
LOCAL nHandle, cBuffer := space( 2 )
nHandle := fopen( "test.dbf" )
IF nHandle > 0
fseek( nHandle, 8 )
fread( nHandle, @cBuffer, 2 )
? "Length of DBF header in bytes:", BIN2W( cBuffer )
fclose( nHandle )
ELSE
? "Can not open file"
ENDIF
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2U(),I2BIN(),L2BIN(),W2BIN(),WORD(),U2BIN(),FREAD()
Index
API

DESCEND()

Inverts an expression of string, logical, date or numeric type.
Syntax
DESCEND( <xExp> ) --> xExpInverted
Argument(s)
<xExp> is any valid expression.
Returns
Inverted value of the same type as passed.
Description
This function converts an expression in his inverted form. It is useful to build descending indexes.
Example(s)
// Seek for Smith in a descending index
SEEK DESCEND( "SMITH" )
Test(s)
DATA->( DBSEEK( DESCEND( "SMITH" ) ) )
will seek "SMITH" into a descending index.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
INDEX, SEEK
Index
API

I2BIN()

Convert Harbour numeric into signed short encoded bytes
Syntax
I2BIN( <nNumber> ) --> cBuffer
Argument(s)
<nNumber> is a numeric value to convert (decimal digits are ignored).
Returns
I2BIN() return two bytes character string that contain 16 bit encoded signed short integer (least significant byte first).
Description
I2BIN() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. I2BIN() take a numeric integer value and convert it into two bytes of encoded 16 bit signed short integer.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
I2BIN() is the opposite of BIN2I()
Example(s)
// Update DBF "last update" date
#include "fileio.ch"
FUNCTION main()
LOCAL nHandle, cYear, cMonth, cDay
use test
? "Original update date is:", lupdate()
close
nHandle := fopen( "test.dbf", FO_READWRITE )
IF nHandle > 0
fseek( nHandle, 1, )
cYear  := I2BIN( 68 )
cMonth := I2BIN(  8 )
cDay   := I2BIN(  1 )
fwrite( nHandle, cYear , 1 )   // write only the first byte
fwrite( nHandle, cMonth, 1 )
fwrite( nHandle, cDay  , 1 )
fclose( nHandle )
use test
? "New update date is:", lupdate()
close
ELSE
? "Can not open file"
ENDIF
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2U(),BIN2W(),L2BIN(),W2BIN(),WORD(),U2BIN(), FWRITE()
Index
API

L2BIN()

Convert Harbour numeric into signed long encoded bytes
Syntax
L2BIN( <nNumber> ) --> cBuffer
Argument(s)
<nNumber> is a numeric value to convert (decimal digits are ignored).
Returns
L2BIN() return four bytes character string that contain 32 bit encoded signed long integer (least significant byte first).
Description
L2BIN() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. L2BIN() take a numeric integer value and convert it into four bytes of encoded 32 bit signed long integer.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
L2BIN() is the opposite of BIN2L()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2U(),BIN2W(),I2BIN(),W2BIN(),WORD(),U2BIN(), FWRITE()
Index
API

U2BIN()

Convert Harbour numeric into unsigned long encoded bytes
Syntax
U2BIN( <nNumber> ) --> cBuffer
Argument(s)
<nNumber> is a numeric value to convert (decimal digits are ignored).
Returns
U2BIN() return four bytes character string that contain 32 bit encoded unsigned long integer (least significant byte first).
Description
U2BIN() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. U2BIN() take a numeric integer value and convert it into four bytes of encoded 32 bit unsigned long integer.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
U2BIN() is the opposite of BIN2U()
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'XPP'
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),W2BIN(),WORD(), FWRITE()
Index
API

W2BIN()

Convert Harbour numeric into unsigned short encoded bytes
Syntax
W2BIN( <nNumber> ) --> cBuffer
Argument(s)
<nNumber> is a numeric value to convert (decimal digits are ignored).
Returns
W2BIN() return two bytes character string that contain 16 bit encoded unsigned short integer (least significant byte first).
Description
W2BIN() is one of the low level binary conversion functions, those functions convert between Harbour numeric and a character representation of numeric value. W2BIN() take a numeric integer value and convert it into two bytes of encoded 16 bit unsigned short integer.
You might ask what is the need for such functions, well, first of all it allow you to read/write information from/to a binary file (like extracting information from DBF header), it is also a useful way to share information from source other than Harbour (C for instance).
W2BIN() is the opposite of BIN2W()
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'XPP'
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2U(),BIN2W(),I2BIN(),L2BIN(),WORD(),U2BIN(), FWRITE()
Index
API

WORD()

Converts double to integer values.
Syntax
WORD( <nDouble> ) --> <nInteger>
Argument(s)
<nDouble> is a numeric double value.
Returns
WORD() return an integer in the range +-32767
Description
This function converts double values to integers to use within the CALL command
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'The CA-Cl*pper NG states that WORD() will only work when used in CALL commands parameter list, otherwise it will return NIL, in Harbour it will work anywhere.'
File(s)
Library is rtl
See also
CALL
Index
API

Database

AFIELDS()*

Fills referenced arrays with database field information
Syntax
AFields(<aNames>[,<aTypes>][,<aLen>][,<aDecs>]) --> <nFields>
Argument(s)
<aNames> Array of field names
<aTypes> Array of field names
<aLens> Array of field names
<aDecs> Array of field names
Returns
<nFields> Number od fields in a database or work area
Description
This function will fill a series of arrays with field names, field types, field lenghts, and number of field decimal positions for the currently selected or designed database. Each array parallels the different descriptors of a file's structure. The first array will consist of the names of the fields in the current work area. All other arrays are optional and will be filled with the corrensponding data. This function will return zero if no parameters are specified or if no database is avaliable in the current work area. Otherwise, the number of fields or the lenght of the shortest array argument, witchever is smaller, will be returned.
AFIELDS() is a compatibility function, it is superseded by DBSTRUCT() which returns one multidimensional array.
NOTE: The destination arrays must be initialized to a given size,
usually FCOUNT(), before calling this function.
Example(s)
FUNCTION Main()
LOCAL aNames, aTypes, aLens, aDecs, nCount, nFields, i
USE Test
nCount := FCount()
? "Number of fields:", nCount
PrintFields( nCount )   // Information for all fields
PrintFields( 4      )   // Information for first 4 fields
RETURN NIL
FUNCTION PrintFields( nCount )
LOCAL aNames, aTypes, aLens, aDecs, nFields, i
aNames  := Array( nCount )
aTypes  := Array( nCount )
aLens   := Array( nCount )
aDecs   := Array( nCount )
nFields := aFields( aNames, aTypes, aLens, aDecs )
? "Number of items :", nFields
FOR i := 1 TO nFields
?  i, PadR( aNames[ i ], 12 ), aTypes[ i ]
?? aLens[ i ], aDecs[ i ]
NEXT
?
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBSTRUCT()
Index
API

ALIAS()

Returns the alias name of a work area
Syntax
Alias([<nWorkArea>]) --> <cWorkArea>
Argument(s)
<nWorkArea> Number of a work area
Returns
<cWorkArea> Name of alias
Description
This function returns the alias of the work area indicated by <nWorkArea> If <nWorkArea> is not provided, the alias of the current work area is returned.
Example(s)
FUNCTION Main()
USE Test
select 0
qOut( IF(Alias()=="","No Name",Alias()))
Test->(qOut(Alias())
qOut(Alias(1))
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBF()
Index
API

BOF()

Test for the beggining-of-file condition
Syntax
BOF() --> <lBegin>
Returns
BOF() Logical true (.T.) or false (.F.)
Description
This function determines if the beggining of the file marker has been reached. If so, the function will return a logical true (.T.); otherwise, a logical false (.F.) will be returned. By default, BOF() will apply to the currently selected database unless the function is preceded by an alias
Example(s)
FUNCTION Main()
USE Tests NEW
DBGOTOP()
? "Is Eof()",EOF()
DBGOBOTTOM()
? "Is Eof()",EOF()
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
EOF(),FOUND(),LASTREC()
Index
API

DBAPPEND()

Appends a new record to a database file.
Syntax
DbAppend( [<lLock>] ) --> NIL
Argument(s)
<lLock> Toggle to release record locks
Returns
DbAppend() always returns NIL
Description
This function add a new record to the end of the database in the selected or aliased work area. All fields in that database will be given empty data values - character fields will be filled with blank spaces,date fields with CTOD('//'), numeric fields with 0, logical fields with .F., and memo fields with NULL bytes. The header of the database is not updated until the record is flushed from the buffer and the contents are written to the disk.
Under a networking enviroment, DBAPPEND() performs an additional operation: It attrmps to lock the newly added record. If the database file is currently locked or if a locking assignment if made to LASTREC()+1, NETERR() will return a logical true (.T.) immediately after the DBAPPEND() function. This function does not unlock the locked records.
If <lLock> is passed a logical true (.T.) value, it will release the record locks, which allows the application to main- tain multiple record locks during an appending operation. The default for this parameter is a logical false (.F.).
Example(s)
FUNCTION Main()
USE Test
local cName="HARBOUR",nId=10
Test->(DbAppend())
Replace Test->Name wit cName,Id with nId
Use
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUNLOCK(),DBUNLOCKALL()
Index
API

DBCLEARFILTER()

Clears the current filter condiction in a work area
Syntax
DbClearFilTer() --> NIL
Returns
DbClearFilTer() always returns NIL
Description
This function clears any active filter condiction for the current or selected work area.
Example(s)
Function Main()
Use Test
Set Filter to Left(Test->Name,2) == "An"
Dbedit()
Test->(DbClearFilter())
USE
Return Nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBSETFILTER(),DBFILTER()
Index
API

DBCLOSEALL()

Close all open files in all work areas.
Syntax
DbCloseAll() --> NIL
Returns
DBCLOSEALL() always return NIL
Description
This function close all open databases and all associated indexes. In addition, it closes all format files and moves the work area pointer to the first position
Example(s)
Function Main()
Use Test New
DbEdit()
Use Test1 New
DbEdit()
DbCloseAll()
USE
Return Nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUSEAREA(),DBCLOSEAREA()
Index
API

DBCLOSEAREA()

Close a database file in a work area.
Syntax
DbCloseArea()
Description
This function will close any database open in the selected or aliased work area.
Example(s)
Function Main()
Use Test
Dbedit()
Test->(DbCloseArea())
USE
Return Nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUSEAREA(),DBCLOSEALL()
Index
API

DBCOMMIT()

Updates all index and database buffers for a given workarea
Syntax
DBCOMMIT()
Description
This function updates all of the information for a give,selected, or active workarea. This operation includes all database and index buffers for that work area only. This function does not update all open work areas.
Example(s)
FUNCTION Main()
LOCAL cName:=SPACE(40)
LOCAL nId:=0
USE Test EXCLUSIVE NEW
//
@ 10, 10 GET cName
@ 11, 10 GET nId
READ
//
IF UPDATED()
APPEND BLANK
REPLACE Tests->Name WITH cName
REPLACE Tests->Id WITH nId
Tests->( DBCOMMIT() )
ENDIF
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBCLOSEALL(),DBCOMMITALL(),DBUNLOCK()
Index
API

DBCOMMITALL()

Flushes the memory buffer and performs a hard-disk write
Syntax
DBCOMMIT()
Description
This function performs a hard-disk write for all work areas. Before the disk write is performed,all buffers are flushed. open work areas.
Example(s)
FUNCTION Main()
LOCAL cName:=SPACE(40)
LOCAL nId:=0
USE Test EXCLUSIVE NEW
USE TestId New INDEX Testid
//
@ 10, 10 GET cName
@ 11, 10 GET nId
READ
//
IF UPDATED()
APPEND BLANK
REPLACE Tests->Name WITH cName
REPLACE Tests->Id WITH nId
IF !TestId->(DBSEEK(nId))
APPEND BLANK
REPLACE Tests->Id WITH nId
ENDIF
ENDIF
DBCOMMITALL()
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBCLOSEALL(),DBCOMMIT(),DBUNLOCK()
Index
API

DBCREATE()

Creates an empty database from a array.
Syntax
DBCREATE( <cDatabase>, <aStruct>, [<cDriver>], [<lOpen>],
[<cAlias>] )
Argument(s)
<cDatabase> Name of database to be create
<aStruct> Name of a multidimensional array that contains the
database structure
<cDriver> Name of the RDD
<lOpenNew> 3-way toggle to Open the file in New or Current workarea:

NIL The file is not opened.
True It is opened in a New area.
False It is opened in the current area.

<cAlias> Name of database Alias
Description
This function creates the database file specified as <cDatabase> from the multidimensional array <aStruct>. If no file extension is use with <cDatabase> the .dbf extension is assumed. The array specified in <aStruct> must follow a few guidelines when being built prior to a call to DBCREATE():
- All subscripts values in the second dimension must be set to proper values
- The fourth subscript value in the second dimension - which contains
the decimal value-must he specified. even 1kw nonnumeric fields.
- The second subscript value in the second dimension-which contains
the field data type-must contain a proper value: C, D, L, M or N It is possible to use additional letters (or clarity (e.g., 'Numeric' for 'N'): however, the first letter of this array element must be a proper value.
The DBCREATE( ) function does not use the decimal field to calculate the length of a character held longer than 256. Values up to the maximum length of a character field (which is 65,519 bytes) are stored directly in the database in the length attribute if that database was created via this function. However, a file containing fields longer than 256 bytes is not compatible with any interpreter.
The <cDriver> parameter specifies the name of the Replaceable Database Driver to use to create the database. If it is not specified, then the Replaceable Database Driver in the current work area is used.
The <lOpenNew> parameter specifies if the already created database is to be opened, and where. If NIL, the file is not opened. If True, it is opened in a New area, and if False it is opened in the current area (closing any file already occupying that area). The <cAlias> parameter specifies the alias name for the new opened database.
Example(s)
function main()
local nI, aStruct := { { "CHARACTER", "C", 25, 0 }, ;
{ "NUMERIC",   "N",  8, 0 }, ;
{ "DOUBLE",    "N",  8, 2 }, ;
{ "DATE",      "D",  8, 0 }, ;
{ "LOGICAL",   "L",  1, 0 }, ;
{ "MEMO1",     "M", 10, 0 }, ;
{ "MEMO2",     "M", 10, 0 } }
REQUEST DBFCDX
dbCreate( "testdbf", aStruct, "DBFCDX", .t., "MYALIAS" )
RETURN NIL
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is not CA-Cl*pper compliant'
File(s)
Library is rdd Header is dbstruct.ch
See also
AFIELDS()*,DBSTRUCT()
Index
API

DBDELETE()

Mark a record for deletion in a database.
Syntax
DBDELETE()
Description
This function marks a record for deletion in the selected or aliased work area. If the DELETED setting is on, the record will still be visible until the record pointer in that work area is moved to another record.
In a networking situation, this function requires that the record be locked prior to issuing the DBDELETE() function.
Example(s)
nId:=10
USE TestId INDEX TestId NEW
IF TestId->(DBSEEK(nId))
IF TestId->(RLOCK())
DBDELETE()
ENDIF
ENDIF
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBRECALL()
Index
API

DBF()

Alias name of a work area
Syntax
Dbf() --> <cWorkArea>
Returns
<cWorkArea> Name of alias
Description
This function returns the same alias name ofthe currently selected work area.
Example(s)
FUNCTION Main()
USE Test
select 0
qOut( IF(DBF()=="","No Name",DBF()))
Test->(qOut(DBF())
qOut(Alias(1))
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
ALIAS()
Index
API

DBFILTER()

Return the filter expression in a work area
Syntax
DBFILTER() --> cFilter
Returns
DBFILTER() returns the filter expression.
Description
This function return the expression of the SET FILTER TO command for the current or designated work area. If no filter condition is present, a NULL string will be returned.
Example(s)
USE Test INDEX Test NEW
SET FILTER TO Name= "Harbour"
USE TestId INDEX TestId NEW
SET FILTER TO Id = 1
SELECT Test
//
? DBFILTER()
? TestId->(DBFILTER())
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBRELATION(),DBRSELECT()
Index
API

DBGOBOTTOM()

Moves the record pointer to the bottom of the database.
Syntax
DBGOBOTTOM()
Description
This function moves the record pointer in the selected or aliased work area to the end of the file. The position of the record pointer is affected by the values in the index key or by an active FILTER condition. Otherwise, if no index is active or if no filter condition is present, the value of the record pointer will be LASTREC().
Example(s)
USE Tests
DBGOTOP()
? RECNO()
DBGOBOTTOM()
? RECNO()
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
BOF(),EOF(),DBSKIP(),DBSEEK(),DBGOTOP()
Index
API

DBGOTO()

Position the record pointer to a specific location.
Syntax
DBGOTO(<xRecordNumber>)
Argument(s)
<xRecordNumber> Record number or unique identity
Description
This function places the record pointer, if working with a .dbf file, in selected or aliased work area at the record number specified by <xRecordNumber>. The position is not affected by an active index or by any enviromental SET condiction.
The parameter <xRecordNumber> may be something other than a record number. In some data formats, for example, the value of <xRecordNumber> is a unique primary key while in other formats, <xRecordNumber> could be an array offset if the data set was an array.
Issuing a DBGOTO(RECNO()) call in a network enviroment will refresh the database and index buffers. This is the same as a DBSKIP(0) call.
Example(s)
The following example uses DBGOTO() to iteratively process
every fourth record:
DBUSEAREA( .T., "DBFNTX", "Sales", "Sales", .T. )
//
// toggle every fourth record
DO WHILE !EOF()
DBGOTO( RECNO() + 4 )
Sales->Group := "Bear"
ENDDO
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
BOF(),EOF(),DBGOTOP(),DBGOBOTTOM(),DBSEEK(),DBSKIP()
Index
API

DBGOTOP()

Moves the record pointer to the top of the database.
Syntax
DBGOTOP()
Description
This function moves the record pointer in the selected or aliased work area to the top of the file. The position of the record pointer is affected by the values in the index key or by an active FILTER condition. Otherwise, if no index is active or if no filter condition is present, the value of RECNO() will be 1.
Example(s)
USE Tests
DBGOTOP()
? RECNO()
DBGOBOTTOM()
? RECNO()
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
BOF(),EOF(),DBSKIP(),DBSEEK(),DBGOBOTTOM()
Index
API

DBRECALL()

Recalls a record previousy marked for deletion.
Syntax
DBRECALL()
Description
This function unmarks those records marked for deletion and reactivates them in the aliased or selected work area. If a record is DELETED and the DELETED setting is on, the record will still be visible for a DBRECALL() provided that the database record pointer has not been skipped. Once a record marked for deletion with the DELETE setting ON has been skipped, it no longer can be brought back with DBRECALL().
Example(s)
USE Test NEW
DBGOTO(10)
DBDELETE()
? DELETED()
DBRECALL()
? DELETED()
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBDELETE()
Index
API

DBRLOCK()

This function locks the record based on identity
Syntax
DBRLOCK([<xIdentity>]) --> lSuccess
Argument(s)
<xIdentity> Record identifier
Returns
DBRLOCK() returns a logical true (.T.) if lock was successful
Description
This function attempts to lock a record which is identified by <xIdentity> in the active data set. If the lock is successful the function will return a logical true (.T.) value; otherwise a logical false (.F.) will be returned. If <xIdentity> is not passed it will be assumed to lock the current active record/data item.
Example(s)
FUNCTION Main()
LOCAL x:=0
USE Tests New
FOR x:=1 to reccount()
IF !DBRLOCK()
DBUNLOCK()
ENDIF
NEXT
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUNLOCK(),DBUNLOCKALL(),FLOCK(),RLOCK()
Index
API

DBRLOCKLIST()

This function return a list of locked records in the database work area
Syntax
DBRLOCKLIST() --> aRecordLocks
Returns
<aRecordList> is an array of lock records
Description
This function will return an array of locked records in a given and active work area. If the return array is an empty array (meaning no elements in it), then there are no locked records in that work area.
Example(s)
FUNCTION Main()
LOCAL aList:={}
LOCAL x:=0
USE Tests NEW
DBGOTO(10)
RLOCK()
DBGOTO(100)
RLOCK()
aList:=DBRLOCKLIST()
FOR x:=1 TO LEN(aList)
? aList[x]
NEXT
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
RLOCK(),DBRLOCK(),DBRUNLOCK()
Index
API

DBRUNLOCK()

Unlocks a record based on its identifier
Syntax
DBRUNLOCK([<xIdentity>])
Argument(s)
<xIdentity> Record identifier, typically a record number
Description
This function will attempt to unlock the record specified as <xIdentity>, which in a .dbf format is the record number. If not specified, them the current active record/data item will be unlocked
Example(s)
FUNCTION Main()
USE Tests New
DBGOTO(10)
IF RLOCK()
? Tests->ID
DBRUNLOCK()
ENDIF
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
RLOCK(),DBRLOCK(),DBRLOCKLIST()
Index
API

DBSEEK()

Searches for a value based on an active index.
Syntax
DBSEEK(<expKey>, [<lSoftSeek>],[<lFindLast>]) --> lFound
Argument(s)
<expKey> Any expression
<lSoftSeek> Toggle SOFTSEEK condition
<lFindLast> is an optional logical value that set the current record position to the last record if successful
Returns
DBSEEK() returns logical true (.T.) if found, otherwise false
Description
This function searches for the first record in a database file whose index key matches <expKey>. If the item is found, the function will return a logical true (.T.), the value of FOUND() wilI be a logical true (.T.), and the value of EOF() wilI be a logical false (.F.). If no item is found. then the function will return a logical false, the value of FOUND( ) will be a logical false (.F.), and the value of EOF( ) will be a logical true (.T.).
This function always "rewinds" the database pointer and starts the search from the top of the file.
If the SOFTSEEK flag is on or if <lSoftSeek> is set to a logical true (.T.) the value of FOUND() will be a logical false and EOF() will be false if there is an item in the index key with a greater value than the key expression <expKey>; at this point the record pointer will position itself on that record. However, if there is no greater key in the index,EOF() will return a logical true (.T.) value. If <lSoftSeek> is not passed, the function will look to the internal status of SOFTSEEK before performing the operation. The default of <lSoftSeek> is a logical false (.F.)
Example(s)
FUNCTION Main()
USE Tests New INDEX Tests
DBGOTO(10)
nId:=Tests->nId
IF Tests->(DBSEEK(nId))
IF RLOCK()
? Tests->Name
DBRUNLOCK()
ENDIF
ENDIF
USE
RETURN NIL
ACCEPT "Employee name: " TO cName
IF ( Employee->(DBSEEK(cName)) )
Employee->(ViewRecord())
ELSE
? "Not found"
END
Status
Started
Compliance
Unknown 'COMPLIANCE' code: 'DBSEEK() is Compatible with CA-Cl*pper 5. 3'
File(s)
Library is rdd
See also
DBGOBOTTOM(),DBGOTOP(),DBSKIP(),EOF(),BOF(),FOUND()
Index
API

DBSELECTAREA()

Change to another work area
Syntax
DBSELECTAREA(<xArea>) -
Argument(s)
<xArea> Alias or work area
Description
This function moves the Harbour internal primary focus to the work area designated by <xArea>. If <xArea> is numeric, then it will select the numeric work area; if <xArea> is character,then it will select the work area with the alias name.
DBSELECTAREA(0) will select the next avaliable and unused work area. Up to 255 work areas are supported. Each work area has its own alias and record pointer, as well as its own FOUND(), DBFILTER(), DBRSELECT() and DBRELATION() function values.
Example(s)
FUNCTION Main()
LOCAL nId
USE Tests NEW INDEX Tests
USE Tests1 NEW INDEX Tests1
DBSELECTAREA(1)
nId:=Tests->Id
DBSELECTAREA(2)
IF DBSEEK(nId)
? Tests1->cName
ENDIF
DBCLOSEALL()
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUSEAREA(),SELECT()
Index
API

DBSETDRIVER()

Establishes the RDD name for the selected work area
Syntax
DBSETDRIVER( [<cDriver>] ) --> cCurrentDriver
Argument(s)
<cDriver> Optional database driver name
Returns
DBSETDRIVER() returns the name of active driver
Description
This function returns the name of the current database driver for the selected work area. The default will be "DBFNTX". If specified, <cDriver> contains the name of the database driver that should be used to activate and manage the work area. If the specified driver is not avaliable,this function will have no effect.
Example(s)
DBSETDRIVER("ADS")
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUSEAREA()
Index
API

DBSETFILTER()

Establishes a filter condition for a work area.
Syntax
DBSETFILTER(<bCondition>, [<cCondition>])
Argument(s)
<bCondition> Code block expression for filtered evaluation.
<cCondition> Optional character expression of code block.
Description
This function masks a database so that only those records that meet the condition prescribed by the expression in the code block <bCondition> and literally expressed as <cCondition> are visible. If <cCondition> is not passed to this function,then the DBFILTER() function will return an empty string showing no filter in that work area which in fact,would be not correct.
Example(s)
FUNCTION Main()
USE Tests NEW
DBSETFILTER( {|| Tests->Id <100 }, "Tests->Id <100" )
DBGOTOP()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBFILTER(),DBCLEARFILTER()
Index
API

DBSKIP()

Moves the record pointer in the selected work area.
Syntax
DBSKIP([<nRecords>])
Argument(s)
<nRecords> Numbers of records to move record pointer.
Description
This function moves the record pointer <nRecords> in the selected or aliased work area. The default value for <nRecords> will be 1. A DBSKIP(0) will flush and refresh the internal database bufer and make any changes made to the record visible without moving the record pointer in either direction.
Example(s)
FUNCTION Main()
USE Tests NEW
DBGOTOP()
WHILE !EOF()
? Tests->Id, Tests->Name
DBSKIP()
ENDDO
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
BOF(),DBGOBOTTOM(),DBGOTOP(),DBSEEK(),EOF()
Index
API

DBSTRUCT()

Creates a multidimensional array of a database structure.
Syntax
DBSTRUCT() --> aStruct
Returns
DBSTRUCT() returns an array pointer to database structure
Description
This function returns a multidimensional array. This array has array pointers to other arrays,each of which contains the characteristic of a field in the active work area. The lenght of this array is based in the number of fields in that particular work area. In other words, LEN(DBSTRUCT()) is equal to the value obtained from FCOUNT(). Each subscript position
Example(s)
FUNCTION Main()
LOCAL aStru,x
USE Tests NEW
aStru:=DBSTRUCT()
FOR x:=1 TO LEN(aStru)
? aStru[x,1]
NEXT
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd Header is dbstruct.ch
See also
AFIELDS()*
Index
API

DBUNLOCK()

Unlock a record or release a file lock
Syntax
DBUNLOCK()
Description
This function releases the file or record lock in the currently selected or aliased work area. It will not unlock an associated lock in a related databases.
Example(s)
nId := 10
USE TestId INDEX TestId NEW
IF TestId->(DBSEEK(nId))
IF TestId->(RLOCK())
DBDELETE()
ELSE
DBUNLOCK()
ENDIF
ENDIF
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUNLOCKALL(),FLOCK(),RLOCK()
Index
API

DBUNLOCKALL()

Unlocks all records and releases all file locks in all work areas.
Syntax
DBUNLOCKALL()
Description
This function will remove all file and record locks in all work area.
Example(s)
nId:=10
USE Tests INDEX TestId NEW
USE Tests1 INDEX Tests NEW
IF TestId->(DBSEEK(nId))
IF TestId->(RLOCK())
DBDELETE()
ELSE
DBUNLOCK()
ENDIF
ELSE
DBUNLOCKALL()
ENDIF
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBUNLOCK(),FLOCK(),RLOCK()
Index
API

DBUSEAREA()

Opens a work area and uses a database file.
Syntax
DBUSEAREA( [<lNewArea>], [<cDriver>], <cName>, [<xcAlias>], [<lShared>], [<lReadonly>])
Argument(s)
<lNewArea> A optional logical expression for the new work area
<cDriver> Database driver name
<cName> File Name
<xcAlias> Alias name
<lShared> Shared/exclusive status flag
<lReadonly> Read-write status flag.
Description
This function opens an existing database named <cName> in the current work area. If <lNewArea> is set to a logical true (.T.) value, then the database <cName> will be opened in the next available and unused work area. The default value of <lNewArea> is a logical false (.F.). If used, <cDriver> is the name of the database driver associated with the file <cName> that is opened. The default for this will be the value of DBSETDRlVER().
IF used, <xcAlias> contains the alias name for that work area, If not specified, the root name of the database specified in <cName> will be used.
If <lShared> is set to a logical true (.T.) value, the database that is specified in <cName> will be opened by the user EXCLUSIVELY. Thus locking it from all other nodes or users on the network. If <lShared> is set to a logical false (.F.) value, then the database will be in SHARED mode. If <lShared> is not passed, then the function will turn to the internal setting of SET EXCLUSIVE to determine a setting.
If <lReadOnly> is specified, the file will be set to READ ONLY mode. If it is not specified, the file will he opened in normal read-write mode.
Example(s)
DBUSEAREA(.T.,,"Tests")
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBCLOSEAREA(),DBSETDRIVER(),SELECT(),SET()
Index
API

DELETED()

Tests the record's deletion flag.
Syntax
DELETED() --> lDeleted
Argument(s)
(This command has no arguments)
Returns
DELETED() return a logical true (.T.) or false (.F.).
Description
This function returns a logical true (.T.) is the current record in the selected or designated work area ha ben marked for deletion. If not, the function will return a logical false (.F.).
Example(s)
FUNCTION Main()
USE Test New
DBGOTO()
DBDELETE()
? "Is Record Deleted",Test->(DELETED())
DBRECALL()
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBDELETE()
Index
API

EOF()

Test for end-of-file condition.
Syntax
EOF() --> <lEnd>
Argument(s)
(This command has no arguments)
Returns
<lEnd> A logical true (.T.) or false (.F.)
Description
This function determines if the end-of-file marker has been reached. If it has, the function will return a logical true (.T.); otherwise a logical false (.F.) will be returnd
Example(s)
FUNCTION Main()
USE Tests NEW
DBGOTOP()
? "Is Eof()",EOF()
DBGOBOTTOM()
? "Is Eof()",EOF()
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
BOF(),FOUND(),LASTREC()
Index
API

FCOUNT()

Counts the number of fields in an active database.
Syntax
FCOUNT() --> nFields
Returns
<nFields> Return the number of fields
Description
This function returns the number of fields in the current or designated work area. If no database is open in this work area, the function will return 0.
Example(s)
FUNCTION Main()
USE Tests NEW
? "This database have ",Tests->(FCOUNT()),"Fields"
USE
RETURN Nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
FIELDNAME(),TYPE()
Index
API

FIELDGET()

Obtains the value of a specified field
Syntax
FIELDGET(<nField>) --> ValueField
Argument(s)
<nField> Is the numeric field position
Returns
<ValueField> Any expression
Description
This function returns the value of the field at the <nField>th location in the selected or designed work area. If the value in <nField> does not correspond to n avaliable field position in this work area, the function will return a NIL data type.
Example(s)
FUNCTION Main()
USE Test NEW
? Test->(FieldGet(1))
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
FIELDPUT()
Index
API

FIELDNAME()

Return the name of a field at a numeric field location.
Syntax
FIELDNAME/FIELD(<nPosition>) --> cFieldName
Argument(s)
<nPosition> Field order in the database.
Returns
<cFieldName> returns the field name.
Description
This function return the name of the field at the <nPosition>th position. If the numeric value passed to this function does not correspond to an existing field in the designated or selected work area, this function will return a NULL byte.
Example(s)
FUNCTION Main()
LOCAL x
USE Tests NEW
FOR x := 1 to Tests->(FCOUNT())
? "Field Name",FieldName(x)
NEXT
USE
RETURN Nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBSTRUCT(),FCOUNT(),LEN(),VALTYPE()
Index
API

FIELDPOS()

Return the ordinal position of a field.
Syntax
FIELDPOS(<cFieldName>) --> nFieldPos
Argument(s)
<cFieldName> Name of a field.
Returns
<nFieldPos> is ordinal position of the field.
Description
This function return the ordinal position of the specified field <cField> in the current or aliased work areaIf there isn't field under the name of <cField> or of no database is open in the selected work area, the func- tion will return a 0.
Example(s)
FUNCTION Main()
USE Test NEW
? Test->(FIELDPOS("ID"))
USE
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
FIELDGET(),FIELDPUT()
Index
API

FIELDPUT()

Set the value of a field variable
Syntax
FIELDPUT(<nField>, <expAssign>) --> ValueAssigned
Argument(s)
<nField> The field numeric position
<expAssign> Expression to be assigned to the specified field
Returns
<ValueAssigned> Any expression
Description
This function assings the value in <expAssing> to the <nField>th field in the current or designated work area. If the operation is successful, the return value of the function will be the same value assigned to the specified field. If the operation is not successful, the function will return a NIL data type
Example(s)
USE Tests New
FIELDPUT(1,"Mr. Jones")
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
FIELDGET()
Index
API

FLOCK()

Locks a file
Syntax
FLOCK() --> lSuccess
Returns
<lSuccess> A true (.T.) value, if the lock was successful;otherwise false (.F.)
Description
This function returns a logical true (.T.) if a file lock is attempted and is successfully placed on the current or designated database. This function will also unlock all records locks placed by the same network station.
Example(s)
USE Tests New
IF FLOCK()
SUM Tests->Ammount
ENDIF
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
RLOCK()
Index
API

FOUND()

Determine the success of a previous search operation.
Syntax
FOUND() --> lSuccess
Argument(s)
(This function has no arguments)
Returns
<lSuccess> A logical true (.T.) is successful; otherwise, false (.F.)
Description
This function is used to test if the previous SEEK, LOCATE, CONTINUE, or FIND operation was successful. Each wrk area has its own FOUND() flag, so that a FOUND() condition may be tested in unselected work areas by using an alias.
Example(s)
nId:=100
USE Tests NEW INDEX Tests
SEEK nId
IF FOUND()
? Tests->Name
ENDIF
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
EOF()
Index
API

HEADER()

Return the length of a database file header
Syntax
HEADER() --> nBytes
Returns
<nBytes> The numeric size of a database file header in bytes
Description
This function returns the number of bytes in the header of the selected database ot the database in the designated work area.
If used in conjunction with the LASTREC(), RECSIZE() and DISKSPACE() functions, this functions is capable of implementing a backup and restore routine.
Example(s)
USE Tests New
? Header()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DISKSPACE(),LASTREC(),RECSIZE()
Index
API

INDEXEXT()

Returns the file extension of the index module used in an application
Syntax
INDEXEXT() --> <cExtension>
Argument(s)
None.
Returns
<cExtension> Current driver file extension
Description
This function returns a string that tells what indexes are to be used or will be created in the compiled application. The default value is ".ntx". This is controled by the particular database driver that is linked with the application.
Example(s)
IF INDEXEXT()==".ntx"
? "Current driver being used is DBFNTX"
Endif
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
INDEXKEY(),INDEXORD()
Index
API

INDEXKEY()

Yields the key expression of a specified index file.
Syntax
INDEXKEY(<nOrder>) --> <cIndexKey>
Argument(s)
<nOrder> Index order number
Returns
<cIndexKey> The index key
Description
This function returns a character string stored in the header of the index file
The index key is displayed for an index file that is designated by <nOrder>, its position in the USE...INDEX or SET INDEX TO command in the currently selected or designated work area. If there is no corresnponding index key at the specified order position, a NULL byte will be returned.
Example(s)
USE TESTS NEW INDEX TEST1
? INDEXKEY(1)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
INDEXORD()
Index
API

INDEXORD()

Returns the numeric position of the controlling index.
Syntax
INDEXORD() --> <nPosition>
Argument(s)
None.
Returns
<nPosition> Ordinal position of a controling index
Description
The INDEXORD() function returns the numeric position of the current controlling index in the selected or designated work area. A returned value of 0 indicated that no active index is controlling the database, which therefore is in the natural order.
Example(s)
USE TESTS NEW INDEX TEST1
IF INDEXORD()>0
? "Current order is ",INDEXORD()
Endif
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
INDEXKEY()
Index
API

LASTREC()

Returns the number of records in an active work area or database.
Syntax
LASTREC() | RECCOUNT()* --> nRecords
Returns
<nRecords > The number of records
Description
This function returns the number of records present in the database in the selected or designated work area. If no records are present the value of this function will be 0. Additionaly, if no database is in use in the selected or designated work area, this function will return a 0 value as well.
Example(s)
USE Tests NEW
? LASTREC(), RECCOUNT()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
EOF()
Index
API

LUPDATE()

Yields the date the database was last updated.
Syntax
LUPDATE() --> dModification
Argument(s)
(This function has no arguments)
Returns
<dModification> The date of the last modification.
Description
This function returns the date recorded by the OS when the selected or designated database was last written to disk. This function will only work for those database files in USE.
Example(s)
Function Main
Use Tests New
? Lupdate() // 04/25/2000
Use
Return Nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
FIELDNAME(),LASTREC(),RECSIZE()
Index
API

NETERR()

Tests the success of a network function
Syntax
NETERR([<lNewError>]) --> lError
Argument(s)
<lNewError> Is a logical Expression.
Returns
<lError> A value based on the success of a network operation or function.
Description
This function return a logical true (.T.) is a USE, APPEND BLANK, or a USE...EXCLUSIVE command is issue and fails in a network enviroment. In the case of USE and USE...EXCLUSIVE commands, a NETERR() value of .T. would be returned if another node of the network has the exclusive use of a file. And the case of the APPEND BLANK command, NETERR() will return a logical true (.T.) if the file or record is locked by another node or the value of LASTREC() has been advanced The value of NETERR() may be changed via the value of <lNewError>. This allow the run-time error-handling system to control the way certains errors are handled.
Example(s)
USE TEST NEW Index Test
If !NetErr()
Seek Test->Name="HARBOUR"
If Found()
? Test->Name
Endif
Endif
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
FLOCK(),RLOCK()
Index
API

ORDBAGEXT()

Returns the Order Bag extension
Syntax
ORDBAGEXT() --> cBagExt
Argument(s)
None
Returns
<cBagExt> The RDD extension name.
Description
This function return th character name of the RDD extension for the order bag. This is determined by the active RDD for the selected work area.
This function replaces the Indexord() function.
Example(s)
USE Tests NEW VIA "DBFNTX"
? ORDBAGEXT()      //  Returns .ntx
DBCLOSEAREA()
USE Tests NEW VIA "DBFCDX"
? ORDBAGEXT()      //  Returns .cdx
DBCLOSEAREA()
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
INDEXEXT(),ORDBAGNAME()
Index
API

ORDBAGNAME()

Returns the Order Bag Name.
Syntax
ORDBAGNAME(<nOrder> | <cOrderName>) --> cOrderBagName
Argument(s)
<nOrder> A numeric value representing the Order bag number.
<cOrderName> The character name of the Order Bag.
Returns
ORDBAGNAME() returns the Order bag name
Description
This function returns the name of the order bag for the specified work area. If <nOrder> is specidied, it will represent the position in the order list of the target order. If <cOrderName> is specified, it will represent the name of the target order. In essence, it will tell the name of the database (if That Rdd is in use) for a given index name or index order number. If <cOrderName> is not specified or <nOrder> is 0, the Current active order will be used.
Example(s)
USE Tests VIA "DBFCDX" NEW
Set index to TESTs
ORDBAGNAME( "TeName" )        // Returns: Customer
ORDBAGNAME( "TeLast" )        // Returns: Customer
ORDBAGNAME( "teZip" )         // Returns: Customer
Set Order to Tag TeName
? OrderBagName() //Return Custumer
Test(s)
See Examples
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
INDEXORD(),ORDBAGEXT(),ALIAS()
Index
API

ORDCONDSET()

Set the Condition and scope for an order
Syntax
ORDCONSET([<cForCondition>],
[<bForCondition>], [<lAll>], [<bWhileCondition>], [<bEval>], [<nInterval>], [<nStart>], [<nNext>], [<nRecord>], [<lRest>], [<lDescend>], [<lAdditive>], [<lCurrent>], [<lCustom>], [<lNoOptimize>])
Argument(s)
<cForCondition> is a string that specifies the FOR condition for the order.
<bForCondition> is a code block that defines a FOR condition that
each record within the scope must meet in order to be processed. If a record does not meet the specified condition, it is ignored and the next record is processed.Duplicate keys values are not added to the index file when a FOR condition is Used.
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
Index
API

ORDCREATE()

Create an Order in an Order Bag
Syntax
ORDCREATE(<cOrderBagName>,[<cOrderName>], <cExpKey>, [<bExpKey>], [<lUnique>])
Argument(s)
<cOrderBagName> Name of the file that contains one or more Orders.
<cOrderName> Name of the order to be created.
<cExpKey> Key value for order for each record in the current work area
<bExpKey> Code block that evaluates to a key for the order for each record in the work area.
<lUnique> Toggle the unique status of the index.
Description
This function creates an order for the current work area. It is similar to the DBCREATEINDEX() except that this function allows different orders based on the RDD in effect. The name of the file <cOrderBagName> or the name of the order <cOrderName> are technically both considered to be "optional" except that at least one of two must exist in order to create the order.
The parameter <cExpKey> is the index key expression; typically in a . dbf driver, the maximum length of the key is 255 characters.
If <bExpKey> is not specified, then the code block is create by macro expanding the value of <cExpKey>.
If <lUnique> is not specified, then the current internal setting of SET UNIQUE ON or OFF will be observed.
The active RDD driver determines the capacity in the order for a specific order bag.
If the name <cOrderBagName> is found in the order bag can contain a single order, the the name <cOrderBagName> is erased and a new order is added to the order list in the current or specified work area.On the other hand, if it can contain multiples tags and if <cOrderBagName> does not already exist in the order list, then it is added. It is does exist, then the <cOrderBagName> replaces the former name in the order list in the current or specified work area.
Example(s)
USE TESTS VIA "DBFNDX" NEW
ORDCREATE( "FNAME",, "Tests->fName" )
USE TEsts VIA "DBFCDX" NEW
ORDCREATE( , "lName", "tests->lName" )
Test(s)
See examples
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
DBCREATEINDEX(),ORDNAME(),ORDSETFOCUS()
Index
API

ORDDESTROY()

Remove an Order from an Order Bag
Syntax
ORDDESTROY(<cOrderName> [, <cOrderBagName> ])
Argument(s)
<cOrderName> Name of the order to remove
<cOrderBagName> Name of the order bag from which order id to be removed
Description
This function attempts to remove the order named <cOrderName> from the file containing the order bag name <cOrderBagName>. If <cOrderBagName> is not specified, then the name of the file will be based on the value of the ORDNAME() function. If the extension is not included with the name of the order file, then the extension will be obtained from the default extension of the current and active RDD.
The DBFNTX driver do not support multiple order bags; therefore, there cannot be an order to "destroy" from a bag. This function only works for those drivers with support multiple orders bags (e.q. DBFCDX and RDDADS drivers).
Example(s)
USE Tests VIA "DBFCDX" NEW
ORDdestroy( "lName", "tests" )
Test(s)
See examples
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
ORDCREATE()
Index
API

ORDFOR()

Return the FOR expression of an Order
Syntax
ORDFOR(<xOrder>[, <cOrderBagName>]) --> cForExp
Argument(s)
<xOrder> It the name of the target order,or the numeric position of the order.
<cOrderBagName> Name of the order bag.
Returns
ORDFOR() returns a expression containing the FOR condition for an order.
Description
This function returns a character string that is the expression for the FOR condition for the specified order. The order may be specified if <xOrder> is the name of the order.However,<xOrder> may be an numeric which represent the position in the order list of the desired Order.
Example(s)
USE Tests NEW via _DBFCDX
INDEX ON  Tests->Id ;
TO  TESTS          ;
FOR Tests->Id > 100
ORDFOR( "Tests" )      // Returns: Tests->Id > 100
Test(s)
See examples
Status
Started
Compliance
Unknown 'COMPLIANCE' code: 'This function is CA-Cl*pper compliant with one exception: If the <xOrder> paramter is not specified or <xOrder> is 0, the current active order is used.'
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
ORDKEY(),ORDCREATE(),ORDNAME(),ORDNUMBER()
Index
API

ORDKEY()

Return the key expression of an Order
Syntax
ORDKEY(<cOrderName> | <nOrder> [, <cOrderBagName>]) --> cExpKey
Argument(s)
<xOrder> It the name of the target order,or the numeric position of the order.
<cOrderBagName> Name of the order bag.
Returns
<cExpKey> Returns a character string, cExpKey.
Example(s)
USE Tests NEW via _DBFCDX
INDEX ON  Tests->fName ;
TO  Tests           ;
FOR Tests->fName > "CK"
Index on Tests->Id to TestId
ORDKEY( "Tests" )      // Returns: Tests->fName
Set order to 2
ORDKEY()               // Returns: Tests->Id
Status
Started
Compliance
Unknown 'COMPLIANCE' code: 'This function is CA-Cl*pper compliant with one exception: If the <xOrder> paramter is not specified or <xOrder> is 0, the current active order is used.'
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
ORDFOR(),ORDNAME(),ORDNUMBER(),ORDKEY()
Index
API

RECCOUNT()

Counts the number of records in a database.
Syntax
RECCOUNT()* | LASTREC() --> nRecords
Argument(s)
(This function has no arguments)
Returns
<nRecords> The number of records
$DESCRIPTION$*
This function returns the number of records present in the database in the selected or designated work area. If no records are present the value of this function will be 0. Additionaly, if no database is in use in the selected or designated work area, this function will return a 0 value as well.
Example(s)
Use Test NEW
USE Harbour NEW
? Reccount()
? Test->(RECCOUNT())
CLOSE ALL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
EOF(),LASTREC(),RECNO(),DBGOBOTTOM()
Index
API

RECNO()

Returns the current record number or identity.
Syntax
RECNO() --> Identity
Argument(s)
(This function has no arguments)
Returns
RECNO() The record number or identity
Description
This function returns the position of the record pointer in the currently selected ot designated work area.
If the database file is empty and if the RDD is the traditional .dbf file, the value of this function will be 1.
Example(s)
USE Tests NEW
DBGOTOP()
RECNO()            // Returns 1
DBGOTO(50)
RECNO()            // Returns 50
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DBGOTO(),DBGOTOP(),DBGOBOTTOM(),LASTREC(),EOF(),BOF()
Index
API

RECSIZE()

Returns the size of a single record in an active database.
Syntax
RECSIZE() --> nBytes
Argument(s)
(This function has no arguments)
Returns
<nBytes> The record size.
Description
This function returns the number os bytes used by a single record in the currently selected or designated database file. If no database is in use in this work area, the return value from this function will be 0.
Example(s)
USE Tests NEW
DBGOTOP()
RECSIZE()            // Returns 1
DBGOTO(50)
RECSIZE()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
DISKSPACE(),FIELDNAME(),HEADER(),LASTREC()
Index
API

RLOCK()

Lock a record in a work area
Syntax
RLOCK() --> lSuccess
Argument(s)
(This function has no arguments)
Returns
RLOCK() True (.T.) if record lock is successful; otherwise, it returns false (.F.).
Description
This function returns a logical true (.T.) if an attempt to lock a specific record in a selected or designated work area is successful. It will yield a false (.F.) if either the file or the desired record is currently locked. A record that is locked remains locked until another RLOCK() is issued or until an UNLOCK command is executed. On a Network enviroment the follow command need that the record is locked:
@...GET
DELETE (single record)
RECALL (single record)
REPLACE (single record)
Example(s)
nId:=10
USE TestId INDEX TestId NEW
IF TestId->(DBSEEK(nId))
IF TestId->(RLOCK())
DBDELETE()
ENDIF
ENDIF
USE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
FLOCK()
Index
API

SELECT()

Returns the work area number for a specified alias.
Syntax
SELECT([<cAlias>]) --> nWorkArea
Argument(s)
<cAlias> is the target work area alias name.
Returns
SELECT() returns the work area number.
Description
This function returns the work area number for the specified alias name <cAlias>. If no parameter is specified, the current work area will be the return value of the function.
Example(s)
USE TESTS NEW
USE NAMES NEW
cOldArea:=SELECT("NAMES")
select TEST
LIST
SELECT cOldArea
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
ALIAS(), USED()
Index
API

USED()

Checks whether a database is in use in a work area
Syntax
USED() --> lDbfOpen
Argument(s)
(This function has no arguments)
Returns
<lDbfOpen> True is a database is Used;otherwise False
Description
This function returns a logical true (.T.) if a database file is in USE in the current or designated work area. If no alias is specified along with this function , it will default to the currently selected work area.
Example(s)
Use TESTS NEW
USE Names New
? USED()    // .T.
? TESTS->(USED()) //.T.
CLOSE
? USED()  // .F.
Select TESTS
? USED() //.T.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
ALIAS(), SELECT()
Index
API

__FLEDIT()*

Filter a database structure array
Syntax
__FLEDIT( <aStruct>, [<aFieldList>] ) --> aStructFiltered
Argument(s)
<aStruct> is a multidimensional array with database fields structure, which is usually the output from DBSTRUCT(), where each array element has the following structure:

Position Description dbstruct.ch
1 cFieldName DBS_NAME
2 cFieldType DBS_TYPE
3 nFieldLength DBS_LEN
4 nDecimals DBS_DEC

<aFieldList> is an array where each element is a field name. Names could be specified as uppercase or lowercase.
Returns
__FLEDIT() return a new multidimensional array where each element is in the same structure as the original <aStruct>, but the array is built according to the list of fields in <aFieldList>. If <aFieldList> is empty, __FLEDIT() return reference to the original <aStruct> array.
Description
__FLEDIT() can be use to create a sub-set of a database structure, based on a given field list.
Note that field names in <aStruct> MUST be specified in uppercase or else no match would found.
SET EXACT has no effect on the return value.
__FLEDIT() is a compatibility function and it is synonym for __dbStructFilter() which does exactly the same.
Example(s)
LOCAL aStruct, aList, aRet
aStruct := { { "CODE",  "N",  4, 0 }, ;
{ "NAME",  "C", 10, 0 }, ;
{ "PHONE", "C", 13, 0 }, ;
{ "IQ",    "N",  3, 0 } }
aList := { "IQ", "NAME" }
aRet := __FLEDIT( aStruct, aList )
// { { "IQ", "N", 3, 0 }, { "NAME", "C", 10, 0 } }
aRet := __FLEDIT( aStruct, {} )
? aRet == aStruct // .T.
aList := { "iq", "NOTEXIST" }
aRet := __FLEDIT( aStruct, aList )
// { { "IQ", "N", 3, 0 } }
aList := { "NOTEXIST" }
aRet := __FLEDIT( aStruct, aList )   // {}
// Create a new file that contain part of the original structure
LOCAL aStruct, aList, aRet
USE TEST
aStruct := DBSTRUCT()
aList := { "NAME" }
DBCREATE( "onlyname.dbf", __FLEDIT( aStruct, aList ) )
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'CA-Cl*pper has internal undocumented function named __FLEDIT(), in Harbour we name it __dbStructFilter(). The new name gives a better description of what this function does. In Harbour __FLEDIT() simply calls __dbStructFilter() and therefor the latter is the recommended function to use.
This function is only visible if src/rdd/dbstrux.prg was compiled with the HB_CLP_UNDOC flag.'
Platform(s)
This is available on all platforms
File(s)
Header file is dbstruct.ch Library is rdd
See also
DBCREATE(),DBSTRUCT(),__dbCopyStruct(),__dbStructFilter()
Index
API

__dbCopyStruct()

Create a new database based on current database structure
Syntax
__dbCopyStruct( <cFileName>, [<aFieldList>] )
Argument(s)
<cFileName> is the name of the new database file to create. (.dbf) is the default extension if none is given.
<aFieldList> is an array where each element is a field name. Names could be specified as uppercase or lowercase.
Description
__dbCopyStruct() create a new empty database file with a structure that is based on the currently open database in this work-area. If <aFieldList> is empty, the newly created file would have the same structure as the currently open database. Else, the new file would contain only fields that exactly match <aFieldList>.
__dbCopyStruct() can be use to create a sub-set of the currently open database, based on a given field list.
COPY STRUCTURE command is preprocessed into __dbCopyStruct() function during compile time.
Example(s)
// Create a new file that contain the same structure
USE TEST
__dbCopyStruct( "mycopy.dbf" )
// Create a new file that contain part of the original structure
LOCAL aList
USE TEST
aList := { "NAME" }
__dbCopyStruct( "onlyname.dbf", aList )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
COPY STRUCTURE,COPY STRUCTURE EXTENDED,DBCREATE(),DBSTRUCT(), __dbCopyXStruct(),__dbCreate(),__dbStructFilter()
Index
API

__dbCopyXStruct()

Copy current database structure into a definition file
Syntax
__dbCopyXStruct( <cFileName> ) --> lSuccess
Argument(s)
<cFileName> is the name of target definition file to create. (.dbf) is the default extension if none is given.
Returns
__dbCopyXStruct() returns .F. if no database is USED in the current work-area, .T. on success, or a run-time error if the file create operation had failed.
Description
__dbCopyXStruct() create a new database named <cFileName> with a pre-defined structure (also called "structure extended file"):

Field name Type Length Decimals
FIELD_NAME C 10 0
FIELD_TYPE C 1 0
FIELD_LEN N 3 0
FIELD_DEC N 3 0

Each record in the new file contains information about one field in the original file. CREATE FROM could be used to create a database from the structure extended file.
For prehistoric compatibility reasons, Character fields which are longer than 255 characters are treated in a special way by writing part of the length in the FIELD_DEC according to the following formula (this is done internally):
<fixed> FIELD->FIELD_DEC := int( nLength / 256 ) FIELD->FIELD_LEN := ( nLength % 256 ) </fixed>
Later if you want to calculate the length of a field you can use the following formula:
<fixed> nLength := IIF( FIELD->FIELD_TYPE == "C", ;
FIELD->FIELD_DEC * 256 + FIELD->FIELD_LEN, ; FIELD->FIELD_LEN )
</fixed>
COPY STRUCTURE EXTENDED command is preprocessed into __dbCopyXStruct() function during compile time.
Example(s)
// Open a database, then copy its structure to a new file,
// Open the new file and list all its records
USE Test
__dbCopyXStruct( "TestStru" )
USE TestStru
LIST
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
COPY STRUCTURE,COPY STRUCTURE EXTENDED,CREATE,CREATE FROM,DBCREATE(), DBSTRUCT(),__dbCopyStruct(),__dbCreate()
Index
API

__dbCreate()

Create structure extended file or use one to create new file
Syntax
__dbCreate( <cFileName>, [<cFileFrom>], [<cRDDName>], [<lNew>], [<cAlias>] ) --> lUsed
Argument(s)
<cFileName> is the target file name to create and then open. (.dbf) is the default extension if none is given.
<cFileFrom> is an optional structure extended file name from which the target file <cFileName> is going to be built. If omitted, a new empty structure extended file with the name <cFileName> is created and opened in the current work-area.
<cRDDName> is RDD name to create target with. If omitted, the default RDD is used.
<lNew> is an optional logical expression, (.T.) opens the target file name <cFileName> in the next available unused work-area and makes it the current work-area. (.F.) opens the target file in the current work-area. Default value is (.F.). The value of <lNew> is ignored if <cFileFrom> is not specified.
<cAlias> is an optional alias to USE the target file with. If not specified, alias is based on the root name of <cFileName>.
Returns
__dbCreate() returns (.T.) if there is database USED in the current work-area (this might be the newly selected work-area), or (.F.) if there is no database USED. Note that on success a (.T.) would be returned, but on failure you probably end up with a run-time error and not a (.F.) value.
Description
__dbCreate() works in two modes depending on the value of <cFileFrom>:
<b>1)</b> If <cFileFrom> is empty or not specified a new empty structure extended file with the name <cFileName> is created and then opened in the current work-area (<lNew> is ignored). The new file has the following structure:

Field name Type Length Decimals
FIELD_NAME C 10 0
FIELD_TYPE C 1 0
FIELD_LEN N 3 0
FIELD_DEC N 3 0

The CREATE command is preprocessed into the __dbCopyStruct() function during compile time and uses this mode.
<b>2)</b> If <cFileFrom> is specified, it is opened and assumed to be a structure extended file where each record contains at least the following fields (in no particular order): FIELD_NAME, FIELD_TYPE, FIELD_LEN and FIELD_DEC. Any other field is ignored. From this information the file <cFileName> is then created and opened in the current or new work-area (according to <lNew>), if this is a new work-area it becomes the current.
For prehistoric compatibility reasons, structure extended file Character fields which are longer than 255 characters should be treated in a special way by writing part of the length in the FIELD_DEC according to the following formula:
<fixed> FIELD->FIELD_DEC := int( nLength / 256 ) FIELD->FIELD_LEN := ( nLength % 256 ) </fixed>
CREATE FROM command is preprocessed into __dbCopyStruct() function during compile time and use this mode.
Example(s)
// CREATE a new structure extended file, append some records and
// then CREATE FROM this file a new database file
__dbCreate( "template" )
DBAPPEND()
FIELD->FIELD_NAME := "CHANNEL"
FIELD->FIELD_TYPE := "N"
FIELD->FIELD_LEN  := 2
FIELD->FIELD_DEC  := 0
DBAPPEND()
FIELD->FIELD_NAME := "PROGRAM"
FIELD->FIELD_TYPE := "C"
FIELD->FIELD_LEN  := 20
FIELD->FIELD_DEC  := 0
DBAPPEND()
FIELD->FIELD_NAME := "REVIEW"
FIELD->FIELD_TYPE := "C"      // this field is 1000 char long
FIELD->FIELD_LEN  := 232      // 1000 % 256 = 232
FIELD->FIELD_DEC  := 3        // 1000 / 256 = 3
DBCLOSEAREA()
__dbCreate( "TV_Guide", "template" )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rdd
See also
COPY STRUCTURE,COPY STRUCTURE EXTENDED,CREATE,CREATE FROM,DBCREATE(), DBSTRUCT(),__dbCopyStruct(),__dbCopyXStruct()
Index
API

__dbDelim()

Copies the contents of a database to a delimited text file or appends the contents of a delimited text file to a database.
Syntax
__dbDelim( <lExport>, <xcFile>, [<xcDelim>], [<aFields>], [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], <lRest> )
Argument(s)
<lExport> If set to .T., copies records to a delimited file. If set to .F., append records from a delimited file.
<xcFile> The name of the text file to copy to or append from. If a file extension is not specified, ".txt" is used by default.
<xcDelim> Either the character to use as the character field delimiter (only the first character is used). or "BLANK" (not case sensitive), which eliminates the character field delimiters and sets the field separator to a single space instead of a comma.
<aFields> An aray of field names to limit the processint to. If not specified, or if empty, then all fields are processed.
<bFor> An optional code block containing a FOR expression that will reduce the number of records to be processed.
<bWhile> An optional code block containing a WHILE expression that will reduce the number of records to be processed.
<nNext> If present, but nRecord is not present, specifies to process this number of records, starting with the current record. A value of 0 means to process no records.
<nRecord> If present, specifies the only record to process. A value of 0 means to process no records. Overrides <nNext> and <lRest>.
<lRest> If <lExport> is .T., then if <lRest> is set to .T. and there are no <nRecord>, <nNext>, or <bWhile> arguments, processes all records from current to last.
Description
__dbDelim() copies all or selected contents of a database table to an SDF text file or appends all or selected contents of an SDF text file to a database table.
Example(s)
// Copy delinquent accounts into a delimited text file.
USE ACCOUNTS NEW
COPY TO overdue DELIMITED FOR !EMPTY( accounts->duedate ) ;
.AND. DATE() - accounts->duedate > 30
// Import new customer records.
USE CUSTOMER NEW
APPEND FROM customer DELIMITED
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
See also
__dbSDF(), APPEND FROM, COPY TO
Index
API

__dbSDF()

Copies the contents of a database to an SDF text file or appends the contents of an SDF text file to a database.
Syntax
__dbSDF( <lExport>, <xcFile>, [<aFields>], [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], <lRest> )
Argument(s)
<lExport> If set to .T., copies records to an SDF file. If set to .F., append records from an SDF file.
<xcFile> The name of the text file to copy to or append from. If a file extension is not specified, ".txt" is used by default.
<aFields> An aray of field names to limit the processint to. If not specified, or if empty, then all fields are processed.
<bFor> An optional code block containing a FOR expression that will reduce the number of records to be processed.
<bWhile> An optional code block containing a WHILE expression that will reduce the number of records to be processed.
<nNext> If present, but <nRecord> is not present, specifies to process this number of records, starting with the current record. A value of 0 means to process no records.
<nRecord> If present, specifies the only record to process. A value of 0 means to process no records. Overrides <nNext> and <lRest>.
<lRest> If <lExport> is .T., then if <lRest> is set to .T. and there are no <nRecord>, <nNext>, or <bWhile> arguments, processes all records from current to last.
Description
__dbSDF() copies all or selected contents of a database table to an SDF text file or appends all or selected contents of an SDF text file to a database table.
Example(s)
// Copy delinquent accounts into an SDF text file.
USE ACCOUNTS NEW
COPY TO overdue SDF FOR !EMPTY( accounts->duedate ) ;
.AND. DATE() - accounts->duedate > 30
// Import new customer records.
USE CUSTOMER NEW
APPEND FROM customer SDF
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
See also
__dbDelim(), APPEND FROM, COPY TO
Index
API

__dbStructFilter()

Filter a database structure array
Syntax
__dbStructFilter( <aStruct>, [<aFieldList>] ) --> aStructFiltered
Argument(s)
<aStruct> is a multidimensional array with database fields structure, which is usually the output from DBSTRUCT(), where each array element has the following structure:

Position Description dbstruct.ch
1 cFieldName DBS_NAME
2 cFieldType DBS_TYPE
3 nFieldLength DBS_LEN
4 nDecimals DBS_DEC

<aFieldList> is an array where each element is a field name. Names could be specified as uppercase or lowercase.
Returns
__dbStructFilter() return a new multidimensional array where each element is in the same structure as the original <aStruct>, but the array is built according to the list of fields in <aFieldList>. If <aFieldList> is empty, __dbStructFilter() return reference to the original <aStruct> array.
Description
__dbStructFilter() can be use to create a sub-set of a database structure, based on a given field list.
Note that field names in <aStruct> MUST be specified in uppercase or else no match would be found.
SET EXACT has no effect on the return value.
Example(s)
LOCAL aStruct, aList, aRet
aStruct := { { "CODE",  "N",  4, 0 }, ;
{ "NAME",  "C", 10, 0 }, ;
{ "PHONE", "C", 13, 0 }, ;
{ "IQ",    "N",  3, 0 } }
aList := { "IQ", "NAME" }
aRet := __dbStructFilter( aStruct, aList )
// { { "IQ", "N", 3, 0 }, { "NAME", "C", 10, 0 } }
aRet := __dbStructFilter( aStruct, {} )
? aRet == aStruct // .T.
aList := { "iq", "NOTEXIST" }
aRet := __dbStructFilter( aStruct, aList )
// { { "IQ", "N", 3, 0 } }
aList := { "NOTEXIST" }
aRet := __dbStructFilter( aStruct, aList )   // {}
// Create a new file that contain part of the original structure
LOCAL aStruct, aList, aRet
USE TEST
aStruct := DBSTRUCT()
aList := { "NAME" }
DBCREATE( "onlyname.dbf", __dbStructFilter( aStruct, aList ) )
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: '__dbStructFilter() is a Harbour extension. CA-Cl*pper has an internal undocumented function named __FLEDIT() that does exactly the same thing. The new name gives a better description of what this function does.'
Platform(s)
This is available on all platforms
File(s)
Header file is dbstruct.ch Library is rdd
See also
DBCREATE(),DBSTRUCT(),__dbCopyStruct(),__FLEDIT()*
Index
API

Date/Time

CDOW()

Converts a date to the day of week
Syntax
CDOW(<dDate>) --> cDay
Argument(s)
<dDate> Any date expression.
Returns
<cDay> The current day of week.
Description
This function returns a character string of the day of the week, from a date expression <dDate> passed to it. If a NULL date is passed to the function, the value of the function will be a NULL byte.
Example(s)
? CDOW(DATE())
if CDOW(DATE()+10) =="SUNDAY"
? "This is a sunny day."
Endif
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DAY(),DOW(),DATE(),CMONTH()
Index
API

CMONTH()

Return the name of the month.
Syntax
CMONTH(<dDate>) --> cMonth
Argument(s)
<dDate> Any date expression.
Returns
<cMonth> The current month name
Description
This function returns the name of the month (January,February,etc.) from a date expression <dDate> passed to it. If a NULL date is passed to the function, the value of the function will be a NULL byte.
Example(s)
? CMONTH(DATE())
if CMONTH(DATE()+10) =="March"
? "Have you done your system BACKUP?"
Endif
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
CDOW(),DATE(),MONTH(),YEAR(),DOW(),DTOC()
Index
API

CTOD()

Converts a character string to a date expression
Syntax
CTOD(<cDateString>) --> dDate
Argument(s)
<cDateString> A character date in format 'mm/dd/yy'
Returns
<dDate> A date expression
Description
This function converts a date that has been entered as a character expression to a date expression. The character expression will be in the form "MM/DD/YY" (based on the default value in SET DATE) or in the appropriate format specified by the SET DATE TO command. If an improper character string is passed to the function, an empty date value will be returned.
Example(s)
? CTOD('12/21/00')
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SET DATE,DATE(),DTOS()
Index
API

DATE()

Return the Current OS Date
Syntax
DATE() --> dCurDate
Argument(s)
None
Returns
<dCurDate> Current system date.
Description
This function returns the current system date.
Example(s)
? Date()
Test(s)
? "Today is ",Day(date())," of ",cMonth(date())," of ",Year(date())
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
CTOD(),DTOS(),DTOC(),DAY(),MONTH(),CMONTH()
Index
API

DAY()

Return the numeric day of the month.
Syntax
DAY(<cDate>) --> nMonth
Argument(s)
<cDate> Any valid date expression.
Returns
<nMonth> Numeric value of the day of month.
Description
This function returns the numeric value of the day of month from a date.
Example(s)
? Day(DATE())
? Day(DATE()+6325)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
CTOD(),DTOS(),DTOC(),DATE(),MONTH(),CMONTH()
Index
API

DAYS()

Convert elapsed seconds into days
Syntax
DAYS(<nSecs> ) --> nDay
Argument(s)
<nSecs> The number of seconds
Returns
<nDay> The number of days
Description
This function converts <nSecs> seconds to the equivalent number of days; 86399 seconds represents one day, 0 seconds being midnight.
Example(s)
? DAYS(2434234)
? "Has been passed ",DAYS(63251),' since midnight'
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SECONDS(),SECS(),ELAPTIME()
Index
API

DOW()

Value for the day of week.
Syntax
DOW(<dDate>) --> nDay
Argument(s)
<dDate> Any valid date expression
Returns
<nDay> The current day number
Description
This function returns the number representing the day of the week for the date expressed as <dDate>.
Example(s)
? DOW(DATE())
? DOW(DATE()-6584)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DTOC(),CDOW(),DATE(),DTOS(),DAY()
Index
API

DTOC()

Date to character conversion
Syntax
DTOC(<dDateString>) --> cDate
Argument(s)
<dDateString> Any date
Returns
<dDate> Character represention of date
Description
This function converts any date expression (a field or variable) expressed as <dDateString> to a character expression in the default format "MM/DD/YY". The date format expressed by this function is controled in part by the date format specified in the SET DATE command
Example(s)
? DTOC(Date())
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SET DATE,DATE(),DTOS()
Index
API

DTOS()

Date to string conversion
Syntax
DTOS(<dDateString>) --> cDate
Argument(s)
<dDateString> Any date
Returns
<dDate> String notation of the date
Description
This function returns the value of <dDateString> as a character string in the format of YYYYMMDD. If the value of <dDateString> is an empty date, this function will return eight blank spaces.
Example(s)
? DTOS(Date())
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DTOC(),DATE(),DTOS()
Index
API

ELAPTIME()

Calculates elapted time.
Syntax
ELAPTIME(<cStartTime>,<cEndTime>) --> cDiference
Argument(s)
<cStartTime> Start in time as a string format <cEndTime> End time as a string format
Returns
<cDiference> Difference between the times
Description
This function returns a string that shows the difference between the starting time represented as <cStartTime> and the ending time as <cEndTime>. If the stating time is greater then the ending time, the function will assume that the date changed once.
Example(s)
Static cStartTime
Init Proc Startup
cStartTime:=Time()
Exit Proc StartExit
? "You used this program by",ELAPTIME(cStartTime,Time())
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SECS(),SECONDS(),TIME(),DAY()
Index
API

MONTH()

Converts a date expression to a month value
Syntax
MONTH(<dDate>) --> nMonth
Argument(s)
<dDate> Any valid date expression
Returns
<nMonth> Corresponding number of the month in the year, ranging from
0 to 12
Description
This function returns a number that represents the month of a given date expression <dDate>. If a NULL date (CTOD('')) is passed to the function, the value of the function will be 0.
Example(s)
? Month(DATE())
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
CDOW(),DOW(),YEAR(),CMONTH()
Index
API

SECONDS()

Returns the number of elapsed seconds past midnight.
Syntax
SECONDS() --> nSeconds
Argument(s)
None
Returns
<nSeconds> Number of seconds since midnight
Description
This function returns a numeric value representing the number of elapsed seconds based on the current system time. The system time is considered to start at 0 (midnight); it continues up to 86399 seconds. The value of the return expression is displayed in both seconds and hundredths of seconds.
Example(s)
? Seconds()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
TIME()
Index
API

SECS()

Return the number of seconds from the system date.
Syntax
SECS( <cTime> ) --> nSeconds
Argument(s)
<cTime> Character expression in a time string format
Returns
<nSeconds> Number of seconds
Description
This function returns a numeric value that is a number of elapsed seconds from midnight based on a time string given as <cTime>.
Example(s)
? Secs(Time())
? Secs(time()-10)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SECONDS(),ELAPTIME(),TIME()
Index
API

TIME()

Returns the system time as a string
Syntax
TIME() --> cTime
Argument(s)
None
Returns
<cTime> Character string representing time
Description
This function returns the system time represented as a character expression in the format of HH:MM:SS
Example(s)
? Time()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DATE(),SECONDS()
Index
API

YEAR()

Converts the year portion of a date into a numeric value
Syntax
YEAR(<cDate>) --> nYear
Argument(s)
<dDate> Any valid date expression
Returns
<nYear> The year portion of the date.
Description
This function returns the numeric value for the year in <dDate>. This value will always be a four-digit number and is not affected by the setting of the SET CENTURY and SET DATE commands. Addition ally, an empty date expression passed to this function will yield a zero value.
Example(s)
? Year(date())
? year(CTOD("01/25/3251"))
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DAY(),MONTH()
Index
API

Environment

GETE()

Obtains a system environmental setting.
Syntax
GETE(<cEnviroment> ) --> <cReturn>
Argument(s)
<cEnviroment> Enviromental variable to obtain.
Returns
<cReturn> Value of the Environment Variable.
Description
This function yields a string that is the value of the environment variable <cEnviroment>, which is stored at the system level.
If no environment variable is found, an empty string is returned.
Example(s)
? QOUT(GETE('PATH'))
? QOUT(GETE('CONFIG'))
? QOUT(GETE('HARBOURCMD', '-n -l -es2'))
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This is CA-Cl*pper compliant.
The <cDefaultValue> parameter is a Harbour extension.'
Platform(s)
This is available on all platforms
File(s)
src/rtl/gete.c
Library is rtl
See also
GETENV
Index
API

GETENV()

Obtains a system environmental setting.
Syntax
GETENV(<cEnviroment> ) --> <cReturn>
Argument(s)
<cEnviroment> Enviromental variable to obtain.
Returns
<cReturn> Value of the Environment Variable.
Description
This function yields a string that is the value of the environment variable <cEnviroment>, which is stored at the system level.
If no environment variable is found, an empty string is returned.
Example(s)
? QOUT(GETENV('PATH'))
? QOUT(GETENV('CONFIG'))
? QOUT(GETENV('HARBOURCMD', '-n -l -es2'))
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
src/rtl/gete.c
Library is rtl
See also
GETE
Index
API

HB_GETENV()

Obtains a system environmental setting.
Syntax
HB_GETENV(<cEnviroment>, [<cDefaultValue>], [<lApplyCodepage>] ) --> <cReturn>
Argument(s)
<cEnviroment> Enviromental variable to obtain.
<cDefaultValue> Optional value to return if <cEnvironment> is not found.
<lApplyCodepage> optional logical parameter specifing whether to
apply automatic codepage conversion (to the codepage specified by Set( _SET_OSCODEPAGE ) on the obtained value. The default is .T. Note that if the default value is passed and the environment value is not found, this codepage conversion is not performed against the returned default value
Returns
<cReturn> Value of the environment variable or <cDefaultValue> or an empty string.
Description
This function yields a string that is the value of the environment variable <cEnviroment>, which is stored at the system level.
If no environment variable can be found, the value of the function will be <cDefaultValue> if it is passed, else an empty string.
Example(s)
? QOUT(HB_GETENV('PATH'))
? QOUT(HB_GETENV('CONFIG'))
? QOUT(HB_GETENV('HARBOURCMD', '-n -l -es2'))
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/rtl/gete.c Library is rtl
See also
GETENV, GETE
Index
API

OS()

Return the current operating system.
Syntax
OS() --> <cOperatingSystem>
Returns
<cOperatinSystem> The current operating system.
Description
This function will return the current operating system.
Example(s)
? OS()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
src/rtl/version.c
Index
API

RUN

Run an external program.
Syntax
RUN <cCommand>
Argument(s)
<cCommand> Command to execute.
Description
This command runs an external program. Please make sure that you have enough free memory to be able to run the external program. Do not use it to run Terminate and Stay Resident programs (in case of DOS) since that causes several problems.
Example(s)
Run "edit " + cMyTextFile      // Runs an external editor
Run "command"                  // Gives a DOS shell (DOS only)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
src/rtl/run.c Library is rtl
See also
RUN
Index
API

SET()

Changes or evaluated enviromental settings
Syntax
Set(<nSet> [, <xNewSetting> [, <xOption> ] ] ) --> xPreviousSetting
Argument(s)
<nSet> Set Number
<xNewSetting> Any expression to assign a value to the setting
<xOption> Logical expression
<nSet> <xNewSetting> <xOption>
_SET_ALTERNATE <lFlag> | <cOnOff>
If enabled, QOUT() and QQOUT() write to the screen and to a file, provided that a file has been opened or created with _SET_ALTFILE. If disabled, which is the default, QOUT() and QQOUT() only write to the screen (and/or to the PRINTFILE). Defaults to disabled.
_SET_ALTFILE <cFileName> <lAdditive>
When set, creates or opens file to write QOUT() and QQOUT() output to. If <lAdditive> is TRUE and the file already exists, the file is opened and positioned at end of file. Otherwise, the file is created. If a file is already opened, it is closed before the new file is opened or created (even if it is the same file). The default file extension is ".txt". There is no default file name. Call with an empty string to close the file.
_SET_AUTOPEN <lFlag> | <cOnOff>
TODO: Document
_SET_AUTORDER <lFlag> | <cOnOff>
TODO: Document
_SET_AUTOSHARE <lFlag> | <cOnOff>
TODO: Document
_SET_BELL <lFlag> | <cOnOff>
When enabled, the bell sounds when the last position of a GET is reached and/or when a GET validation fails. Disabled by default.
_SET_CANCEL <lFlag> | <cOnOff>
When enabled, which is the default, pressing Alt+C or Ctrl+Break terminates the program. When disabled, both keystrokes can be read by INKEY(). Note: SET KEY has precedence over SET CANCEL.
_SET_COLOR <cColorSet>
Sets the current color scheme, using color pairs in the sequence "<standard>,<enhanced>,<border>,<background>, <unselected>". Each color pair uses the format "<foreground>/<background>". The color codes are space or "N" for black, "B" for blue, "G" for green, "BG" for Cyan, "R" for red, "RB" for magenta, "GR" for brown, "W" for white, "N+" for gray, "B+" for bright blue, "G+" for bright green, "BG+" for bright cyan, "R+" for bright red, "RB+" for bright magenta, "GR+" for yellow, and "W+" for bright white. Special codes are "I" for inverse video, "U" for underline on a monochrome monitor (blue on a color monitor), and "X" for blank. The default color is "W/N,N/W,N, N,N/W".
_SET_CONFIRM <lFlag> | <cOnOff>
If enabled, an exit key must be pressed to leave a GET. If disabled, which is the default, typing past the end will leave a GET.
_SET_CONSOLE <lFlag> | <cOnOff>
If enabled, which is the default, all screen output goes to the screen. When disabled, screen output is suppressed (Note: This setting does not affect OUTSTD() or OUTERR()).
_SET_CURSOR <nCursorType>
If enabled, which is the default, the cursor is displayed on screen. If disabled, the screen cursor is hidden.
_SET_DATEFORMAT <cDateFormat>
Sets the default date format for display, date input, and date conversion. Defaults to American ("mm/dd/yy"). Other formats include ANSI ("yy.mm.dd"), British ("dd/mm/yy"), French ("dd/mm/yy"), German ("dd.mm.yy"), Italian ("dd-mm-yy"), Japan ("yy/mm/dd"), and USA ("mm-dd-yy"). SET CENTURY modifies the date format. SET CENTURY ON replaces the "y"s with "YYYY". SET CENTURY OFF replaces the "y"s with "YY".
_SET_DEBUG <lStatus>
When set to .t., pressing Alt+D activates the debugger. When set to .f., which is the default, Alt+D can be read by INKEY(). (Also affected by AltD(1) and AltD(0))
_SET_DECIMALS <nNumberOfDecimals>
Sets the number of decimal digits to use when displaying printing numeric values when SET FIXED is ON. Defaults to 2. If SET FIXED is OFF, then SET DECIMALS is only used to determine the number of decimal digits to use after using EXP(), LOG(), SQRT(), or division. Other math operations may adjust the number of decimal digits that the result will display. Note: This never affects the precision of a number. Only the display format is affected.
_SET_DEFAULT <cDefaultDirectory>
Sets the default directory in which to open, create and check for files. Defaults to current directory (blank).
_SET_DELETED <lFlag> | <cOnOff>
If enabled, deleted records will be processed. If disabled, which is the default, deleted records will be ignored.
_SET_DELIMCHARS <cDelimiters>
Sets the GET delimiter characters. Defaults to "::".
_SET_DELIMITERS <lFlag> | <cOnOff>
If enabled, GETs are delimited on screen. If disabled, which is the default, no GET delimiters are used.
_SET_DEVICE <cDeviceName>
Selects the output device for DEVOUT(). When set to "PRINTER", all output is sent to the printer device or file set by _SET_PRINTFILE. When set to anything else, all output is sent to the screen. Defaults to "SCREEN".
_SET_EOF <lFlag> | <cOnOff>
Defaults to FALSE on UN*X, but defaults to TRUE on everything else. If set to FALSE, then CHR(26) does not get written when using COPY TO DELIMITED, COPY TO SDF, or when closing any of the various text files that are created using various SET values. [This is a Harbour extension]
_SET_EPOCH <nYear>
Determines how to handle the conversion of 2-digit years to 4 digit years. When a 2-digit year is greater than or equal to the year part of the epoch, the century part of the epoch is added to the year. When a 2-digit year is less than the year part of the epoch, the century part of the epoch is incremented and added to the year. The default epoch is 1900, which converts all 2-digit years to 19xx. Example: If the epoch is set to 1950, 2-digit years in the range from 50 to 99 get converted to 19xx and 2-digit years in the range 00 to 49 get converted to 20xx.
_SET_ESCAPE <lFlag> | <cOnOff>
When enabled, which is the default, pressing Esc will exit a READ. When disabled, pressing Esc during a READ is ignored, unless the Esc key has been assigned to a function using SET KEY.
_SET_EVENTMASK <nEventCodes>
Determines which events INKEY() will respond to. INKEY_MOVE allows mouse movement events. INKEY_LDOWN allows the left mouse button down click. INKEY_LUP allows the left mouse button up click. INKEY_RDOWN allows the right mouse button down click. INKEY_RUP allows the right mouse button up clock. INKEY_KEYBOARD allows keyboard keystrokes. INKEY_ALL allows all of the preceding events. Events may be combined (e.g., using INKEY_LDOWN + INKEY_RUP will allow left mouse button down clicks and right mouse button up clicks). The default is INKEY_KEYBOARD.
_SET_EXACT <lFlag> | <cOnOff>
When enabled, all string comparisons other than "==" exclude trailing spaces when checking for equality. When disabled, which is the default, all string comparisons other than "==" treat two strings as equal if the right hand string is "" or if the right hand string is shorter than or the same length as the left hand string and all of the characters in the right hand string match the corresponding characters in the left hand string.
_SET_EXCLUSIVE <lFlag> | <cOnOff>
When enabled, which is the default, all database files are opened in exclusive mode. When disabled, all database files are opened in shared mode. Note: The EXCLUSIVE and SHARED clauses of the USE command can be used to override this setting.
_SET_EXIT <lFlag> | <cOnOff>
Toggles the use of Uparrow and Dnarrow as READ exit keys. Specifying true (.T.) enables them as exit keys, and false (.F.) disables them. Used internally by the ReadExit() function.
_SET_EXTRA <lFlag> | <cOnOff>
QUESTION: What is this for? It does not affect _SET_EXTRAFILE in CA-Cl*pper!
_SET_EXTRAFILE <cFileName> <lAdditive>
When set, creates or opens file to write QOUT() and QQOUT() output to. If <lAdditive> is TRUE and the file already exists, the file is opened and positioned at end of file. Otherwise, the file is created. If a file is already opened, it is closed before the new file is opened or created (even if it is the same file). The default file extension is ".prn". There is no default file name. Call with an empty string to close the file.
_SET_FIXED <lFlag> | <cOnOff>
When enabled, all numeric values will be displayed and printed with the number of decimal digits set by SET DECIMALS, unless a PICTURE clause is used. When disabled, which is the default, the number of decimal digits that are displayed depends upon a variety of factors. See _SET_DECIMALS for more.
_SET_INSERT <lFlag> | <cOnOff>
When enabled, characters typed in a GET or MEMOEDIT are inserted. When disabled, which is the default, characters typed in a GET or MEMOEDIT overwrite. Note: This setting can also be toggled between on and off by pressing the Insert key during a GET or MEMOEDIT.
_SET_INTENSITY <lFlag> | <cOnOff>
When enabled, which is the default, GETs and PROMPTs are displayed using the enhanced color setting. When disabled, GETs and PROMPTs are displayed using the standard color setting.
_SET_LANGUAGE <cLanguageID>
Specifies the language to be used for Harbour messages. [This is a Harbour extension]
_SET_MARGIN <nColumns>
Sets the left margin for all printed output. The default value is 0. Note: PCOL() reflects the printer's column position including the margin (e.g., SET MARGIN TO 5 followed by DEVPOS(5, 10) makes PCOL() return 15).
_SET_MBLOCKSIZE <nMemoBlockSize>
TODO: Document
_SET_MCENTER <lFlag> | <cOnOff>
If enabled, display PROMPTs centered on the MESSAGE row. If disabled, which is the default, display PROMPTS at column position 0 on the MESSAGE row.
_SET_MESSAGE <nRow>
If set to 0, which is the default, PROMPTs are always suppressed. Otherwise, PROMPTs are displayed on the set row. Note: It is not possible to display prompts on the top-most screen row, because row 0 is reserved for the SCOREBOARD, if enabled.
_SET_MFILEEXT <cMemoFileExt>
TODO: Document
_SET_OPTIMIZE <lFlag> | <cOnOff>
TODO: Document
_SET_PATH <cDirectories>
Specifies a path of directories to search through to locate a file that can't be located in the DEFAULT directory. Defaults to no path (""). Directories must be separated by a semicolon (e.g., "C:\data; C:\more").
_SET_PRINTER <lFlag> | <cOnOff>
If enabled, QOUT() and QQOUT() write to the screen and to a file, provided that a file has been opened or created with _SET_ALTFILE. If disabled, which is the default, QOUT() and QQOUT() only write to the screen (and/or to the ALTFILE).
_SET_PRINTFILE <cFileName> <lAdditive>
When set, creates or opens file to write QOUT(), QQOUT() and DEVOUT() output to. If <lAdditive> is TRUE and the file already exists, the file is opened and positioned at end of file. Otherwise, the file is created. If a file is already opened, it is closed before the new file is opened or created (even if it is the same file). The default file extension is ".prn". The default file name is "PRN", which maps to the default printer device. Call with an empty string to close the file.
_SET_SCOREBOARD <lFlag> | <cOnOff>
When enabled, which is the default, READ and MEMOEDIT display status messages on screen row 0. When disabled, READ and MEMOEDIT status messages are suppressed.
_SET_SCROLLBREAK <lFlag> | <cOnOff>
QUESTION: What is this flag for?
_SET_SOFTSEEK <lFlag> | <cOnOff>
When enabled, a SEEK that fails will position the record pointer to the first key that is higher than the sought after key or to LASTREC() + 1 if there is no higher key. When disabled, which is the default, a SEEK that fails will position the record pointer to LASTREC()+1.
_SET_STRICTREAD <lFlag> | <cOnOff>
TODO: Document
_SET_TYPEAHEAD <nKeyStrokes>
Sets the size of the keyboard typeahead buffer. Defaults to 50. The minimum is 16 and the maximum is 4096.
_SET_UNIQUE <lFlag> | <cOnOff>
When enabled, indexes are not allowed to have duplicate keys. When disabled, indexes are allowed duplicate keys.
_SET_VIDEOMODE <nValue>
TODO: Document
_SET_WRAP <lFlag> | <cOnOff>
When enabled, lightbar menus can be navigated from the last position to the first and from the first position to the last. When disabled, which is the default, there is a hard stop at the first and last positions.
Returns
SET() The current or previous setting
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
Index
API

SETMODE()

Change the video mode to a specified number of rows and columns
Syntax
SETMODE( <nRows>, <nCols> ) --> lSuccess
Argument(s)
<nRows> is the number of rows for the video mode to set.
<nCols> is the number of columns for the video mode to set.
Returns
SETMODE() returns true if the video mode change was successful; otherwise, it returns false.
Description
SETMODE() is a function that change the video mode depend on the video card and monitor combination, to match the number of rows and columns specified. Note that there are only a real few combination or rows/cols pairs that produce the video mode change. The followings are availables for DOS:

12 rows x 40 columns 12 rows x 80 columns
25 rows x 40 columns 25 rows x 80 columns
28 rows x 40 columns 28 rows x 80 columns
50 rows x 40 columns 43 rows x 80 columns
50 rows x 80 columns

The follow modes are avaliable to Windows

25 rows x 40 columns 25 rows x 80 columns
50 rows x 40 columns 43 rows x 80 columns
50 rows x 80 columns

Some modes only are availables for color and/or VGA monitors. Any change produced on the screen size is updated in the values returned by MAXROW() and MAXCOL().
Example(s)
// The first example change to a 12 lines of display mode:
IF SETMODE( 12, 40)
? "Hey man are you blind ?"
ELSE
? "Mom bring me my glasses!"
ENDIF
// Next example change to a 50 lines mode:
IF SETMODE( 50, 80)
? "This wonderful mode was successfully set"
ELSE
? "Wait. this monitor are not made in rubber !"
ENDIF
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'Some of these modes are not availables in CA-Cl*pper'
Platform(s)
Unknown 'PLATFORMS' code: 'DOS,Win'
File(s)
Source is gtdos.c,gtwin.c
See also
MAXCOL(),MAXROW()
Index
API

SETTYPEAHEAD()

Sets the typeahead buffer to given size.
Syntax
SETTYPEAHEAD( <nSize> ) --> <nPreviousSize>
Argument(s)
<nSize> is a valid typeahead size.
Returns
<nPreviousSize> The previous state of _SET_TYPEAHEAD
Description
This function sets the typeahead buffer to a valid given size as is Set( _SET_TYPEAHEAD ) where used.
Example(s)
// Sets typeahead to 12
SetTypeahead( 12 )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
__ACCEPT(),__INPUT()
Index
API

TONE()

Sound a tone with a specified frequency and duration.
Syntax
TONE( <nFrequency>, <nDuration> ) --> NIL
Argument(s)
<nFrequency> A non-negative numeric value that specifies the frequency of the tone in hertz.
<nDuration> A positive numeric value which specifies the duration of the tone in 1/18 of a second units.
Returns
TONE() always returns NIL.
Description
TONE() is a sound function that could be used to irritate the end user, his or her dog, and the surrounding neighborhood. The frequency is limited to the range 0 to 32767 Hz.
Example(s)
If lOk   // Good Sound
TONE(  500, 1 )
TONE( 4000, 1 )
TONE( 2500, 1 )
Else     // Bad Sound
TONE(  300, 1 )
TONE(  499, 5 )
TONE(  700, 5 )
EndIf
Test(s)
TONE( 800, 1 )                         // same as ? CHR(7)
TONE( 32000, 200 )                     // any dogs around yet?
TONE( 130.80, 1 )                      // musical note - C
TONE( 400, 0 )                         // short beep
TONE( 700 )                            // short beep
TONE( 10, 18.2 )                       // 1 second delay
TONE( -1 )                             // 1/18.2 second delay
TONE( )                                // 1/18.2 second delay
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
CHR(),SET BELL
Index
API

VERSION()

Returns the HARBOUR Version or the Harbour/Compiler Version.
Syntax
VERSION() --> <cReturn>
Argument(s)
None
Returns
<cReturn> String containing the Harbour Version
Description
This function returns the current Harbour Version.
Example(s)
? QOUT(VERSION())
"Harbour Terminal: Standard stream console"
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
src/rtl/version.c Library is rtl
See also
OS()
Index
API

__RUN()

Run an external program.
Syntax
__RUN( <cCommand> )
Argument(s)
<cCommand> Command to execute.
Description
This command runs an external program. Ensure that you have enough free memory to be able to run the external program. Do not use it to run 'Terminate and Stay Resident' programs (in case of DOS) since that causes several problems.
Note: This function is what the RUN command preprocesses into.
It is considered bad form to use this function directly. Use the RUN command instead.
Example(s)
__Run( "edit " + cMyTextFile )    // Runs an external editor
__Run( "command" )                // Gives a DOS shell (DOS only)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
src/rtl/run.c Library is rtl
See also
RUN
Index
API

__SETCENTURY()

Set the Current Century
Syntax
__SETCENTURY([<lFlag> | <cOnOff> ] ) --> lPreviousValue
Argument(s)
optional <lFlag> or <cOnOff> (not case sensitive)
.T. or "ON" to enable the century setting (4-digit years) .F. or "OFF" to disable the century setting (2-digit years)
Returns
Either the current or previous century setting as a logical value
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
Index
API

hb_eol()

Returns the newline character(s) to use with the current OS
Syntax
hb_eol() --> cString
Returns
<cString> A character string containing the character or characters required to move the screen cursor or print head to the start of a new line.
Description
Returns a character string containing the character or characters required to move the screen cursor or print head to the start of a new line for the operating system that the program is running on (or thinks it is running on, if an OS emulator is being used).
Under HB_OS_UNIX operating system the return value is the Line-Feed character (0x0a, CHR(10)); with other operating systems (like DOS) the return value is the Carriage-Return plus Line-Feed characters (0x0d 0x0a, CHR(13)+CHR(10)).
Example(s)
// Get the newline character(s) for the current OS.
// Get the newline character(s) for the current OS.
STATIC s_cNewLine
...
s_cNewLine := hb_eol()
...
OutStd( "Hello World!" + s_cNewLine )
Test(s)
? ValType( hb_eol() ) == "C"
? Len( hb_eol() ) == 1
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
OS(),OUTSTD(),OUTERR()
Index
API

Error

BREAK()

Exits from a BEGIN SEQUENCE block
Syntax
BREAK( <xExp> )
Argument(s)
<xExp> is any valid expression. It is always required. If do not want to pass any argument, just use NIL.
Description
This function passes control to the RECOVER statement in a BEGIN SEQUENCE block.
Example(s)
Break( NIL )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
BEGIN SEQUENCE
Index
API

ERRORSYS()

Install default error handler
Syntax
ERRORSYS() --> NIL
Argument(s)
None.
Returns
ERRORSYS() always return NIL.
Description
ERRORSYS() is called upon startup by Harbour and installs the default error handler. Normally you should not call this function directly, instead use ERRORBLOCK() to install your own error handler.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
ERRORBLOCK(),Error class
Index
API

Events

HB_SETKEYSAVE()

Returns a copy of internal set-key list, optionally overwriting
Syntax
HB_SETKEYSAVE( [ <OldKeys> ] )
Argument(s)
<OldKeys> is an optional set-key list from a previous call to HB_SetKeySave(), or NIL to clear current set-key list
Returns
Current set-key list
Description
HB_SetKeySave() is designed to act like the set() function which returns the current state of an environment setting, and optionally assigning a new value. In this case, the "environment setting" is the internal set-key list, and the optional new value is either a value returned from a previous call to SetKeySave() - to restore that list, or the value of NIL to clear the current list.
Example(s)
local aKeys := HB_SetKeySave( NIL )  // removes all current set=keys
... // some other processing
HB_SetKeySave( aKeys )
Test(s)
None definable
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
SETKEY()
Index
API

HB_SetKeyCheck()

Impliments common hot-key activation code
Syntax
HB_SetKeyCheck( <nKey> [, <p1> ][, <p2> ][, <p3> ] )
Argument(s)
<nKey> is a numeric key value to be tested code-block, if executed
<p1>..<p3> are optional parameters that will be passed to the code-block
Returns
True if there is a hot-key associated with <nKey> and it was executed; otherwise False If there is a hot-key association (before checking any condition): - if there is a condition-block, it is passed one parameter - <nKey> - when the hot-key code-block is called, it is passed 1 to 4 parameters, depending on the parameters passed to HB_SetKeyCheck(). Any parameters so passed are directly passed to the code-block, with an additional parameter being <nKey>
Description
HB_SetKeyCheck() is intended as a common interface to the SetKey() functionality for such functions as ACHOICE(), DBEDIT(), MEMOEDIT(), ACCEPT, INPUT, READ, and WAIT
Example(s)
// within ReadModal()
if HB_SetKeyCheck( K_ALT_X, GetActive() )
... // some other processing
endif
// within TBrowse handler
case HB_SetKeyCheck( nInkey, oTBrowse )
return
case nInKey == K_ESC
... // some other processing
Test(s)
None definable
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
SETKEY(),HB_SETKEYSAVE()
Index
API

HB_SetKeyGet()

Determine a set-key code block and condition-block
Syntax
HB_SETKEYGET( <nKey> [, <bConditionByRef> ] )
Argument(s)
<anKey> is an numeric key value
<bConditionByRef> is an optional return-parameter
Returns
Current assigned action-block
Description
The HB_SetKeyGet() function returns the current code-block assigned to a key, and optionally assignes the condition-block to the return-parameter
Example(s)
local bOldF10, bOldF10Cond
bOldF10 := HB_SetKeyGet( K_F10, @bOldF10Cond )
... // some other processing
SetKey( K_F10, bOldF10, bOldF10Cond )
Test(s)
See test code above
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
SETKEY(),HB_SETKEYSAVE(),HB_SETKEYCHECK()
Index
API

SETKEY()

Assign an action block to a key
Syntax
SETKEY( <anKey> [, <bAction> [, <bCondition> ] ] )
Argument(s)
<anKey> is either a numeric key value, or an array of such values
<bAction> is an optional code-block to be assigned
<bCondition> is an optional condition code-block
Returns
Current assigned action-block
Description
The SetKey() function returns the current code-block assigned to a key when called with only the key value. If the action block (and optionally the condition block) are passed, the current block is returned, and the new code block and condition block are stored. A group of keys may be assigned the same code block/condition block by using an array of key values in place on the first parameter.
Example(s)
local bOldF10 := setKey( K_F10, {|| Yahoo() } )
... // some other processing
SetKey( K_F10, bOldF10 )
... // some other processing
bBlock := SetKey( K_SPACE )
if bBlock != NIL ...
// make F10 exit current get, but only if in a get - ignores other
// wait-states such as menus, achoices, etc...
SetKey( K_F10, {|| GetActive():State := GE_WRITE },;
{|| GetActive() != NIL } )
Test(s)
None definable
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'SETKEY() is mostly CA-Cl*pper compliant. The only difference is the addition of the condition code-block parameter, allowing set-keys to be conditionally turned off or on. This condition-block cannot be returned once set - see SetKeyGet()'
File(s)
Library is rtl
See also
HB_SETKEYSAVE()
Index
API

__QUIT()

Terminates an application.
Syntax
__QUIT()
Argument(s)
None
Description
This function terminates the current application and returns to the system.
Example(s)
See Test
Test(s)
function EndApp( lYesNo )
if lYesNo
__Quit()
endif
return nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
QUIT
Index
API

__SetFunction()

Assign a character string to a function key
Syntax
__SetFunction( <nFunctionKey>, [<cString>] ) --> NIL
Argument(s)
<nFunctionKey> is a number in the range 1..40 that represent the function key to be assigned.
<cString> is a character string to set. If <cString> is not specified, the function key is going to be set to NIL releasing by that any previous __SetFunction() or SETKEY() for that function.
Returns
__SetFunction() always return NIL.
Description
__SetFunction() assign a character string with a function key, when this function key is pressed, the keyboard is stuffed with this character string. __SetFunction() has the effect of clearing any SETKEY() previously set to the same function number and vice versa.

nFunctionKey Key to be set
1 .. 12 F1 .. F12
13 .. 20 Shift-F3 .. Shift-F10
21 .. 30 Ctrl-F1 .. Ctrl-F10
31 .. 40 Alt-F1 .. Alt-F10

SET FUNCTION command is preprocessed into __SetFunction() function during compile time.
Example(s)
// Set F1 with a string
CLS
__SetFunction( 1, "I Am Lazy" + CHR( 13 ) )
cTest := SPACE( 20 )
@ 10, 0 SAY "type something or F1 for lazy mode " GET cTest
READ
? cTest
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'Harbour use 11 and 12 to represent F11 and F12, while CA-Cl*pper use 11 and 12 to represent Shift-F1 and Shift-F2.'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
INKEY(),SETKEY(),__Keyboard(),SET KEY
Index
API

__WAIT()

Stops the application until a key is pressed.
Syntax
__WAIT( <cMessage> ) --> <cKey>
Argument(s)
<cMessage> is a string.
Returns
Pressed key.
Description
This function stops the application until a key is pressed. The key must be in the range 32..255. Control keys are not processed.
Example(s)
// Wait for a key stroke
__Wait( "Press a key to continue" )
Test(s)
do while cKey != "Q"
cKey := __Wait( "Press 'Q' to continue" )
end do
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
__ACCEPT(),__INPUT()
Index
API

Execute and execution

DBEVAL()

Performs a code block operation on the current Database
Syntax
DBEVAL( <bBlock>, [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], [<lRest>] ) --> NIL
Argument(s)
<bBlock> Operation that is to be performed
<bFor> Code block for the For condition
<bWhile> Code block for the WHILE condition
<nNext> Number of NEXT records to process
<nRecord> Record number to work on exactly
<lRest> Toggle to rewind record pointer
Returns
DBEVAL() always returns NIL
Description
Performs a code block operation on the current Database
Example(s)
FUNCTION Main()
LOCAL nCount
USE Test
dbGoto( 4 )
? RecNo()
COUNT TO nCount
? RecNo(), nCount
COUNT TO nCount NEXT 10
? RecNo(), nCount
RETURN NIL
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rdd
See also
EVAL()
Index
API

EVAL()

Evaluate a code block
Syntax
EVAL( <bBlock> [, <xVal> [,...]]) --> xExpression
Argument(s)
<bBlock> Code block expression to be evaluated
<xVal> Argument to be passed to the code block expression
<xVal...> Argument list to be passed to the code block expression
Returns
<xExpression> The result of the evaluated code block
Description
This function evaluates the code bloc expressed as <bBlock> and returns its evaluated value. If their are multiple expressions within the code block, the last expression will be value of this function.
If the code block requires parameters to be passed to it,they are specified in the parameter list <xVal> and following. Each parameter is separated by a comma within the expression list.
Example(s)
FUNC MAIN
LOCAL    sbBlock   := {|| NIL }
?  Eval( 1 )
?  Eval( @sbBlock )
? Eval( {|p1| p1 },"A","B")
? Eval( {|p1,p2| p1+p2 },"A","B")
? Eval( {|p1,p2,p3| p1 },"A","B")
Return Nil
Test(s)
See examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is vm
See also
AEVAL(),DBEVAL()
Index
API

FileSys

ADIR()

Fill pre-defined arrays with file/directory information
Syntax
ADIR( [<cFileMask>], [<aName>], [<aSize>], [<aDate>],
[<aTime>], [<aAttr>] ) --> nDirEnries
Argument(s)
<cFileMask> File mask to include in the function return. It could contain path and standard wildcard characters as supported by your OS (like * and ?). If you omit <cFileMask> or if <cFileMask> contains no path, then the path from SET DEFAULT is used.
<aName> Array to fill with file name of files that meet <cFileMask>. Each element is a Character string and include the file name and extension without the path. The name is the long file name as reported by the OS and not necessarily the 8.3 uppercase name.
<aSize> Array to fill with file size of files that meet <cFileMask>. Each element is a Numeric integer for the file size in Bytes. Directories are always zero in size.
<aDate> Array to fill with file last modification date of files that meet <cFileMask>. Each element is of type Date.
<aTime> Array to fill with file last modification time of files that meet <cFileMask>. Each element is a Character string in the format HH:mm:ss.
<aAttr> Array to fill with attribute of files that meet <cFileMask>. Each element is a Character string, see DIRECTORY() for information about attribute values. If you pass array to <aAttr>, the function is going to return files with normal, hidden, system and directory attributes. If <aAttr> is not specified or with type other than Array, only files with normal attribute would return.
Returns
ADIR() return the number of file entries that meet <cFileMask>
Description
ADIR() return the number of files and/or directories that match a specified skeleton, it also fill a series of given arrays with the name, size, date, time and attribute of those files. The passed arrays should pre-initialized to the proper size, see example below. In order to include hidden, system or directories <aAttr> must be specified.
ADIR() is a compatibility function, it is superseded by DIRECTORY() which returns all the information in a multidimensional array.
Example(s)
LOCAL aName, aSize, aDate, aTime, aAttr, nLen, i
nLen := ADIR( "*.jpg" )     // Number of JPG files in this directory
IF nLen > 0
aName := Array( nLen )   // make room to store the information
aSize := Array( nLen )
aDate := Array( nLen )
aTime := Array( nLen )
aAttr := Array( nLen )
ADIR( "*.prg", aName, aSize, aDate, aTime, aAttr )
FOR i = 1 TO nLen
? aName[i], aSize[i], aDate[i], aTime[i], aAttr[i]
NEXT
ELSE
? "This directory is clean from smut"
ENDIF
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: '<aName> is going to be filled with long file name and not necessarily the 8.3 uppercase name.'
File(s)
Library is rtl
See also
ARRAY(),DIRECTORY(),SET DEFAULT
Index
API

CURDIR()

Returns the current OS directory name.
Syntax
CURDIR( [<cDrive>] ) --> cPath
Argument(s)
<cDrive> OS drive letter
Returns
<cPath> Name of directory
Description
This function yields the name of the current OS directory on a specified drive. If <cDrive> is not speficied, the currently logged drive will be used.
This function should not return the leading and trailing (back)slashes.
If an error has been detected by the function, or the current OS directory is the root, the value of the function will be a NULL byte.
Example(s)
? Curdir()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
FILE()
Index
API

DIRCHANGE()

Changes the directory
Syntax
DIRCHANGE( <cDirectory> ) --> nError
Argument(s)
<cDirectory> The name of the directory you want do change into.
Returns
<nError> 0 if directory was successfully changed, otherwise the number of the last error.
Description
This function attempt to change the current directory to the one specidied in <cDirectory>. If this function fail, the it will return the last OS error code number. See FERROR() function for the description of the error.
Example(s)
if DIRCHANGE( "\temp" ) == 0
? "Change to diretory was successfull"
endif
Test(s)
See examples
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is CA-Cl*pper 5.3 compliant'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
MAKEDIR(), DIRREMOVE(), ISDISK(), DISKCHANGE(), DISKNAME(), FERROR()
Index
API

DIRREMOVE()

Attempt to remove an directory
Syntax
DIRREMOVE( <cDirectory> ) --> nError
Argument(s)
<cDirectory> The name of the directory you want to remove.
Returns
<nError> 0 if directory was successfully removed, otherwise the number of the last error.
Description
This function attempt to remove the specified directory in <cDirectory> If this function fail, the it will return the last OS error code number. See FERROR() function for the description of the error.
Example(s)
cDir:= ".\backup"
if DIRREMOVE( cDir ) == 0
? "Remove of directory", cDir, "was successfull"
endif
Test(s)
See examples
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is CA-Cl*pper 5.3 compliant'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
MAKEDIR(), DIRCHANGE(), ISDISK(), DISKCHANGE(), DISKNAME(), FERROR()
Index
API

DISKSPACE()

Get the amount of space available on a disk
Syntax
DISKSPACE( [<nDrive>] ) --> nDiskbytes
Argument(s)
<nDrive> The number of the drive you are requesting info on where 1 = A, 2 = B, etc. For 0 or no parameter, DiskSpace will operate on the current drive. The default is 0
Returns
<nDiskBytes> The number of bytes on the requested disk that match the requested type.
Description
By default, this function will return the number of bytes of free space on the current drive that is available to the user requesting the information.
If information is requested on a disk that is not available, a runtime error 2018 will be raised.
Example(s)
? "You can use : " +Str( DiskSpace() ) + " bytes "
Note: See tests\tstdspac.prg for another example
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
Unknown 'PLATFORMS' code: 'DOS,Win,OS2'
File(s)
Library is rtl Header is fileio.ch
Index
API

FCLOSE()

Closes an open file
Syntax
FCLOSE( <nHandle> ) --> <lSuccess>
Argument(s)
<nHandle> DOS file handle
Returns
<lSuccess> Logical TRUE (.T.) or FALSE (.F.)
Description
This function closes an open file with a dos file handle of <nHandle> and writes the associated DOS buffer to the disk. The <nHandle> value is derived from the FCREATE() or FOPEN() function.
Example(s)
nHandle:=FOPEN('x.txt')
? FSEEK(nHandle, 0, 2)
FCLOSE(nHandle)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
FOPEN(),FCREATE(),FREAD(),FWRITE(),FERROR()
Index
API

FCREATE()

Creates a file.
Syntax
FCREATE( <cFile>, [<nAttribute>] ) --> nHandle
Argument(s)
<cFile> is the name of the file to create.
<nAttribute> Numeric code for the file attributes.
Returns
<nHandle> Numeric file handle to be used in other operations.
Description
This function creates a new file with a filename of <cFile>. The default value of <nAttribute> is 0 and is used to set the attribute byte for the file being created by this function. The return value will be a file handle that is associated with the new file. This number will be between zero to 65,535, inclusive. If an error occurs, the return value of this function will be -1.
If the file <cFile> already exists, the existing file will be truncated to a file length of 0 bytes.
If specified, the following table shows the value for <nAttribute> and their related meaning to the file <cFile> being created by this function.

<nAttribute> fileio.ch Meaning
0 FC_NORMAL Normal/Default,Read/Write
1 FC_READONLY Read-only file attribute is set
2 FC_HIDDEN Hidden,Excluded from normal DIR search
4 FC_SYSTEM Create,Excluded from normal DIR search

Example(s)
IF (nh:=FCREATE("test.txt") <0
? "Cannot create file"
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl Header is fileio.ch
See also
FCLOSE(),FOPEN(),FWRITE(),FREAD(),FERROR()
Index
API

FERASE()

Erase a file from disk
Syntax
FERASE( <cFile> ) --> nSuccess
Argument(s)
<cFile> Name of file to erase.
Returns
<nSuccess> 0 if successful, -1 if not
Description
This function deletes the file specified in <cFile> from the disk. No extensions are assumed. The drive and path my be included in <cFile>; neither the SET DEFAULT not the SET PATH command controls the performance of this function. If the drive or path is not used, the function will look for the file only on the currently selected direcytory on the logged drive.
If the function is able to successfully delete the file from the disk, the value of the function will be 0; otherwise a -1 will be returned. If not successfu, aditional information may be obtained by calling the FERROR() function.
Note: Any file to be removed by FERASE() must still be closed.
Example(s)
IF FERASE("test.txt")==0
? "File successfully erased"
ELSE
? "File can not be deleted"
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
FERROR(),FRENAME()
Index
API

FERROR()

Reports the error status of low-level file functions
Syntax
FERROR() --> <nErrorCode>
Returns
<nErrorCode> Value of the DOS error last encountered by a low-level file function.
FERROR() Return Values

Error Meaning
0 Successful
2 File not found
3 Path not found
4 Too many files open
5 Access denied
6 Invalid handle
8 Insufficient memory
15 Invalid drive specified
19 Attempted to write to a write-protected disk
21 Drive not ready
23 Data CRC error
29 Write fault
30 Read fault
32 Sharing violation
33 Lock Violation

Description
After every low-level file function,this function will return a value that provides additional informationon the status of the last low-level file functions's performance. If the FERROR() function returns a 0, no error was detected. Below is a table of possibles values returned by the FERROR() function.
Example(s)
#include "fileio.ch"
//
nHandle := FCREATE( "temp.txt", FC_NORMAL )
IF FERROR() != 0
? "Cannot create file, DOS error ", FERROR()
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
FCLOSE(),FERASE(),FOPEN(),FWRITE()
Index
API

FILE()

Tests for the existence of file(s)
Syntax
FILE( <cFileSpec> ) --> lExists
Argument(s)
<cFileSpec> Dos Skeleton or file name to find.
Returns
<lExists> a logical true (.T.) if the file exists or logical false (.F.).
Description
This function return a logical true (.T.) if the given filename <cFileSpec> exist.
Dos skeletons symbols may be used in the filename in <cFileSpec>, as may the drive and/or path name. If a path is not explicity specified, FILE() will look for the file in the SET DEFAULT path, then in each SET PATH path, until the file is found or there are no more paths to search. The DOS PATH is never searched and the current drive/directory is only searched if SET DEFAULT is blank.
Example(s)
? file('C:\harbour\doc\compiler.txt")
? file('C:/harbour/doc/subcodes.txt")
Status
S (wild card support is missing)
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
SET DEFAULT,SET PATH,SET()
Index
API

FOPEN()

Open a file.
Syntax
FOPEN( <cFile>, [<nMode>] ) --> nHandle
Argument(s)
<cFile> Name of file to open.
<nMode> Dos file open mode.
Returns
<nHandle> A file handle.
Description
This function opens a file expressed as <cFile> and returns a file handle to be used with other low-level file functions. The value of <nMode> represents the status of the file to be opened; the default value is 0. The file open modes are as follows:

nMode fileio.ch Meaning
0 FO_READ Read only
1 FO_WRITE Write only
2 FO_READWRITE Read/write
16 FO_EXCLUSIVE Exclusive read only
32 FO_DENYWRITE Prevent others from writing
48 FO_DENYREAD Deny read only
64 FO_DENYNONE Not deny, Let to others Read / Write
64 FO_SHARED same as FO_DENYNONE

If there is an error in opening a file, a -1 will be returned by the function. Files handles may be in the range of 0 to 65535. The status of the SET DEFAULT TO and SET PATH TO commands has no effect on this function. Directory names and paths must be specified along with the file that is to be opened.
If an error has occured, see the returns values from FERROR() for possible reasons for the error.
Example(s)
IF (nH:=FOPEN('x.txt',66) < 0
? 'File can't be opened'
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl Header is fileio.ch
See also
FCREATE(),FERROR(),FCLOSE()
Index
API

FREAD()

Reads a specified number of bytes from a file.
Syntax
FREAD( <nHandle>, @<cBuffer>, <nBytes> ) --> nBytes
Argument(s)
<nHandle> Dos file handle
<cBuffer> Character expression passed by reference.
<nBytes> Number of bytes to read.
Returns
<nBytes> the number of bytes successfully read from the file. <nHandle>
Description
This function reads the characters from a file whose file handle is <nHandle> into a character memory variable expressed as <cBuffer>. The function returns the number of bytes successfully read into <cBuffer>.
The value of <nHandle> is obtained from either a call to the FOPEN() or the FCREATE() function.
The <cBuffer> expression is passed by reference and must be defined before this function is called. It also must be at least the same length as <nBytes>.
<nBytes> is the number of bytes to read, starting at the current file pointer position. If this function is successful in reading the characters from the file, the length of <cBuffer> or the number of bytes specified in <nBytes> will be the value returned. The current file pointer advances the number of bytes read with each successive read. The return value is the number of bytes successfully read from the file. If a 0 is returned, or if the number of bytes read matches neither the length of <cBuffer> nor the specified value in <nBytes> an end-of-file condition has been reached.
Example(s)
cBuffer:=SPACE(500)
IF (nH:=FOPEN('x.txt'))>0
FREAD(nH,@cBuffer,500)
? cbuffer
ENDIF
FCLOSE(nH)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2W(),FERROR(),FWRITE()
Index
API

FREADSTR()

Reads a string from a file.
Syntax
FREADSTR(<nHandle>, <nBytes>) --> cString
Argument(s)
<nHandle> DOS file handle number.
<nBytes> Number of bytes to read.
Returns
<cString> an characted expression
Description
This function returns a character string of <nBytes> bytes from a file whose DOS file handle is <nHandle>.
The value of the file handle <nHandle> is obtained from either the FOPEN() or FCREATE() functions.
The value of <nBytes> is the number of bytes to read from the file. The returned string will be the number of characters specified in <nBytes> or the number of bytes read before an end-of-file charac- ter (ASCII 26) is found.
NOTE This function is similar to the FREAD() function, except that it will not read binary characters that may he required as part of a header of a file construct. Characters Such as CHR(0) and CHR(26) may keep this function from performing its intended operation. In this event, the FREAD() function should he used in place of the FREADSTR() function.
Example(s)
IF ( nH := FOPEN("x.txt") ) > 0
cStr := Freadstr(nH,100)
? cStr
ENDIF
FCLOSE(nH)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
BIN2I(),BIN2L(),BIN2W(),FERROR(),FREAD(),FSEEK()
Index
API

FRENAME()

Renames a file
Syntax
FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess
Argument(s)
<cOldFile> Old filenarne to he changed
<cNewFile> New filename
Returns
<nSuccess> If sucessful, a 0 will he returned otherwise, a -1 will be returned.
Description
This function renames the specified file <cOldFile> to <cNewFile>. A filename and/or directory name may be specified for either para- meter. However, if a path is supplied as part of <cNewFile> and this path is different from either the path specified in <cOldFile> or (if none is used) the current drive and directory, the function will not execute successfully.
Neither parameter is subject to the control of the SET PATH TO or SET DEFAULT TO commands. In attempting to locate the file to be renamed, this function will search the default drive and directory or the drive and path specified in <cOldFile>. It will not search directories named by the SET PATH TO and SET DEFAULT TO commands or by the DOS PATH statement.
If the file specified in <cNewFile> exists or the file is open, the function will be unable to rename the file. If the function is unable to complete its operation,it will return a value of -1. If it is able to rename the file, the return value for the function will be 0. A call to FERROR() function will give additional infor- mation about any error found.
Example(s)
nResult := FRENAME( "x.txt", "x1.txt" )
IF nResult < 0
? "File could not be renamed."
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
ERASE,FERASE(),FERROR(),FILE(),RENAME
Index
API

FSEEK()

Positions the file pointer in a file.
Syntax
FSEEK( <nHandle>, <nOffset>, [<nOrigin>] ) --> nPosition
Argument(s)
<nHandle> DOS file handle.
<nOffset> The number of bytes to move.
<nOrigin> The relative position in the file.
Returns
<nPosition> the current position relative to begin-of-file
Description
This function sets the file pointer in the file whose DOS file handle is <nHandle> and moves the file pointer by <expN2> bytes from the file position designated by <nOrigin>. The returned value is the relative position of the file pointer to the beginning-of-file marker once the operation has been completed.
<nHandle> is the file handle number. It is obtained from the FOPEN() or FCREATE() function.
The value of <nOffSet> is the number of bytes to move the file pointer from the position determined by <nOrigin>. The value of <nOffset> may be a negative number, suggesting backward movement.
The value of <nOrigin> designates the starting point from which the file pointer should he moved, as shown in the following table:

<nOrigin> fileio.ch File position
0 FS_SET Beginning of file
1 FS_RELATIVE Current file pointer position
2 FS_END End of file

If a value is not provided for <nOrigin>, it defaults to 0 and moves the file pointer from the beginning of the file.
Example(s)
// here is a function that read one text line from an open file
// nH = file handle obtained from FOPEN()
// cB = a string buffer passed-by-reference to hold the result
// nMaxLine = maximum number of bytes to read
FUNCTION FREADln( nH, cB, nMaxLine )
LOCAL cLine, nSavePos, nEol, nNumRead
cLine := space( nMaxLine )
cB := ''
nSavePos := FSEEK( nH, 0, FS_RELATIVE )
nNumRead := FREAD( nH, @cLine, nMaxLine )
IF ( nEol := AT( hb_eol(), substr( cLine, 1, nNumRead ) ) ) == 0
cB := cLine
ELSE
cB := SUBSTR( cLine, 1, nEol - 1 )
FSEEK( nH, nSavePos + nEol + 1, FS_SET )
ENDIF
RETURN nNumRead != 0
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl Header is fileio.ch
See also
FCREATE(),FERROR(),FOPEN(),FREAD(),FREADSTR(),FWRITE()
Index
API

FWRITE()

Writes characters to a file.
Syntax
FWRITE( <nHandle>, <cBuffer>, [<nBytes>] ) --> nBytesWritten
Argument(s)
<nHandle> DOS file handle number.
<cBuffer> Character expression to be written.
<nBytes> The number of bytes to write.
Returns
<nBytesWritten> the number of bytes successfully written.
Description
This function writes the contents of <cBuffer> to the file designated by its file handle <nHandle>. If used, <nBytes> is the number of bytes in <cBuffer> to write.
The returned value is the number of bytes successfully written to the DOS file. If the returned value is 0, an error has occurred (unless this is intended). A successful write occurs when the number returned by FWRITE() is equal to either LEN( <cBuffer>) or <nBytes>.
The value of <cBuffer> is the string or variable to be written to the open DOS file <nHandle>.
The value of <nBytes> is the number of bytes to write out to the file. The disk write begins with the current file position in <nHandle>. If this variable is not used, the entire contents of <cBuffer> is written to the file. To truncate a file, a call of FWRITE( nHandle, "", 0 ) is needed.
Example(s)
nHandle := FCREATE( "x.txt" )
FOR X := 1 TO 10
FWRITE( nHandle, STR( x ) )
NEXT
FCLOSE( nHandle )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
FCLOSE(), FCREATE(), FERROR(), FOPEN(), I2BIN(), L2BIN()
Index
API

HB_DISKSPACE()

Get the amount of space available on a disk
Syntax
HB_DISKSPACE( [<cDrive>] [, <nType>] ) --> nDiskbytes
Argument(s)
<cDrive> The drive letter you are requesting info on. The default is A:
<nType> The type of space being requested. The default is HB_DISK_AVAIL.
Returns
<nDiskBytes> The number of bytes on the requested disk that match the requested type.
Description
By default, this function will return the number of bytes of free space on the current drive that is available to the user requesting the information.
There are 4 types of information available:
HB_FS_AVAIL The amount of space available to the user making the
request. This value could be less than HB_FS_FREE if disk quotas are supported by the O/S in use at runtime, and disk quotas are in effect. Otherwise, the value will be equal to that returned for HB_FS_FREE.
HB_FS_FREE The actual amount of free diskspace on the drive.
HB_FS_USED The number of bytes in use on the disk.
HB_FS_TOTAL The total amount of space allocated for the user if
disk quotas are in effect, otherwise, the actual size of the drive.
If information is requested on a disk that is not available, a runtime error 2018 will be raised.
Example(s)
? "You can use : " + Str( HB_DiskSpace() ) + " bytes " +;
"Out of a total of " + Str( HB_DiskSpace( "C:", HB_FS_TOTAL ) )
Note: See tests\tstdspac.prg for another example
Status
Ready
Compliance
This is Harbour specific
Platform(s)
Unknown 'PLATFORMS' code: 'DOS,Win,OS2,Unix'
File(s)
Library is rtl Header is fileio.ch
Index
API

HB_FEOF()

Check for end-of-file.
Syntax
HB_FEOF( <nHandle> ) --> lIsEof
Argument(s)
<nHandle> The handle of an open file.
Returns
<lIsEof> .T. if the file handle is at end-of-file, otherwise .F.
Description
This function checks an open file handle to see if it is at EOF.
If the file handle is missing, not numeric, or not open, then this function returns .T. and sets the value returned by FERROR() to -1 (FS_ERROR) or a C-compiler dependent errno value (EBADF or EINVAL).
Example(s)
nH := FOPEN( "file.txt" )
? FREADSTR( nH, 80 )
IF HB_FEOF( nH )
? "End-of-file reached."
ELSE
? FREADSTR( nH, 80 )
ENDIF
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
FERROR()
Index
API

ISDISK()

Verify if a drive is ready
Syntax
ISDISK( <cDrive> ) --> lSuccess
Argument(s)
<cDrive> An valid Drive letter
Returns
<lSuccess> .T. is the drive is ready, otherwise .F.
Description
This function attempts to access a drive. If the access to the drive was successfull, it will return true (.T.), otherwise false(.F.). This function is usefull for backup function, so you can determine if the drive that will recieve the backup data is ready or not.
Example(s)
IF ISDISK( "A" )
? "Drive is ready "
Endif
Test(s)
See Examples
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is CA-Cl*pper 5.3 compliant'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DIRCHANGE(), MAKEDIR(), DIRREMOVE(), DISKCHANGE(), DISKNAME()
Index
API

MAKEDIR()

Create a new directory
Syntax
MAKEDIR( <cDirectory> ) --> nError
Argument(s)
<cDirectory> The name of the directory you want to create.
Returns
<nError> 0 if directory was successfully created, otherwise the number of the last error.
Description
This function attempt to create a new directory with the name contained in <cDirectory>. If this function fail, the it will return the last OS error code number. See FERROR() function for the description of the error
Example(s)
cDir := "temp"
If MAKEDIR( cDir ) == 0
? "Directory ", cDir, " successfully created
Endif
Test(s)
See examples
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is CA-Cl*pper 5.3 compliant'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
DIRCHANGE(), DIRREMOVE(), ISDISK(), DISKCHANGE(), DISKNAME(), FERROR()
Index
API

__Dir()*

Display listings of files
Syntax
__Dir( [<cFileMask>] ) --> NIL
Argument(s)
<cFileMask> File mask to include in the function return. It could contain path and standard wildcard characters as supported by your OS (like * and ?). If <cFileMask> contains no path, then SET DEFAULT path is used to display files in the mask.
Returns
__Dir() always returns NIL.
Description
If no <cFileMask> is given, __Dir() displays information about all *.dbf in the SET DEFAULT path. This information contains: file name, number of records, last update date and the size of each file.
If <cFileMask> is given, __Dir() list all files that match the mask with the following details: Name, Extension, Size, Date.
DIR command is preprocessed into __Dir() function during compile time.
__Dir() is a compatibility function, it is superseded by DIRECTORY() which return all the information in a multidimensional array.
Example(s)
__Dir()      // information for all DBF files in current directory
__Dir( "*.dbf" )         // list all DBF file in current directory
// list all PRG files in Harbour Run-Time library
// for DOS compatible operating systems
__Dir( "C:\harbour\source\rtl\*.prg" )
// list all files in the public section on a Unix like machine
__Dir( "/pub" )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms.
If long file names are available Harbour will use/display the first 15 characters else Harbour will use/display a 8.3 file name consistent with CA-Cl*pper
File(s)
Library is rtl
See also
ADIR(),DIRECTORY(),SET DEFAULT,DIR
Index
API

Garbage collector

HB_GCALL()

Scans the memory and releases all garbage memory blocks.
Syntax
HB_GCALL()
Argument(s)
None
Description
This function releases all memory blocks that are considered as the garbage.
Status
Harbour
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/vm/garbage.c
See also
hb_gcCollectAll()
Index
API

hb_gcAlloc()

Allocates memory that will be collected by the garbage collector.
Syntax
#include <hbapi.h> void *hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc );
Argument(s)
<ulSize> Requested size of memory block
<pCleanupFunc> Pointer to HB_GARBAGE_FUNC function that will be called directly before releasing the garbage memory block or NULL. This function should release all other memory allocated and stored inside the memory block. For example, it releases all items stored inside the array. The functions receives a single parameter: the pointer to memory allocated by hb_gcAlloc().
Returns
The pointer to allocated memory or it generates an internal unrecoverable error.
Description
hb_gcAlloc() is used to allocate the memory that will be tracked by the garbage collector. It allows to properly release memory in case of self-referencing or cross-referencing harbour level variables. Memory allocated with this function should be released with hb_gcFree() function or it will be automatically deallocated by the GC if it is not locked or if it is not referenced by some harbour level variable.
Example(s)
See src/vm/arrays.c
Status
Unknown 'STATUS' code: 'C'
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/vm/garbage.c
See also
hb_gcFree()
Index
API

hb_gcCollectAll()

Scans all memory blocks and releases the garbage memory.
Syntax
void hb_gcCollectAll( void );
Argument(s)
None.
Returns
Nothing.
Description
This function scans the eval stack, the memvars table, the array of static variables and table of created classes for referenced memory blocks. After scanning all unused memory blocks and blocks that are not locked are released.
Status
Unknown 'STATUS' code: 'C'
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/vm/garbage.c
See also
hb_gcAlloc(),hb_gcFree()
Index
API

hb_gcFree()

Releases the memory that was allocated with hb_gcAlloc().
Syntax
void hb_gcFree( void *pMemoryPtr );
Argument(s)
<pMemoryPtr> The pointer to memory for release. This memory
pointer have to be allocated with hb_gcAlloc() function.
Returns
Nothing.
Description
hb_gcFree() is used to deallocate the memory that was allocated with the hb_gcAlloc() function.
Example(s)
See src/vm/arrays.c
Status
Unknown 'STATUS' code: 'C'
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/vm/garbage.c
See also
hb_gcAlloc()
Index
API

hb_gcItemRef()

Marks the memory to prevent deallocation by the garbage collector.
Syntax
void hb_gcItemRef( PHB_ITEM pItem );
Argument(s)
<pItem> The pointer to item structure that will be scanned. The passed item can be of any datatype although arrays, objects and codeblocks are scanned only. Other datatypes don't require locking so they are simply ignored.
Returns
Nothing.
Description
The garbage collector uses hb_gcItemRef() function during scanning of referenced memory pointers. This function checks the type of passed item and scans recursively all other memory blocks referenced by this item if it is an array, an object or a codeblock.
NOTE: This function is reserved for the garbage collector only. It
cannot be called from the user code - calling it can cause unpredicted results (memory blocks referenced by the passed item can be released prematurely during the closest garbage collection).
Status
Unknown 'STATUS' code: 'C'
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/vm/garbage.c
See also
hb_gcAlloc(),hb_gcFree()
Index
API

Hash table

HB_HALLOCATE()

Preallocates a hash table
Syntax
HB_HALLOCATE( <hsTable>, <nItems> )
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<nItems> number of items to preallocate in the hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HASH()

Returns a hash table
Syntax
HB_HASH( [ <Key1>, <Value1> ], [ <KeyN>, <ValueN> ], ... ) -> hsTable
Argument(s)
<Key1> entry key; can be of type: number, date, datetime, string, pointer
<Value1> entry value; can be of type: block, string, numeric, date/datetime, logical, nil, pointer, array, hash table
Returns
A hash table built from the initial key/value pairs
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HAUTOADD()

Sets the 'auto add' flag for the hash table
Syntax
HB_HAUTOADD( <hsTable>, [<lFlag>] ) -> <lPreviousFlag>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<lFlag> a logical value indicating to turn on or off the 'auto add' flag of the hash table
Returns
The previous value of the 'auto add' flag
Description
This function is equivalent to HB_HAUTOADD() but it returns the old flag value rather than the hash table
Example(s)
LOCAL hsTable, lFlag
hsTable := HB_HASH( "one", 1, "two", 2 )
// turn 'auto add' on for a new hash table, storing ol flag
lFlag := HB_HAUTOADD( hsTable, .T. )
Status
Ready
Compliance
This is Harbour specific
See also
HB_HSETAUTOADD()
Index
API

HB_HBINARY()

Sets the 'binary' flag for the hash table
Syntax
HB_HBINARY( <hsTable>, [<lFlag>] ) -> <lPreviousFlag>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<lFlag> a logical value indicating to turn on or off the 'binary' flag of the hash table
Returns
The previous value of the 'binary' flag
Description
This function is equivalent to HB_HBINARY() but it returns the old flag value rather than the hash table
Example(s)
LOCAL hsTable, lFlag
hsTable := HB_HASH( "one", 1, "two", 2 )
// turn 'binary' on for a new hash table, storing ol flag
lFlag := HB_HBINARY( hsTable, .T. )
Status
Ready
Compliance
This is Harbour specific
See also
HB_HSETBINARY()
Index
API

HB_HCASEMATCH()

Sets the 'case match' flag for the hash table
Syntax
HB_HCASEMATCH( <hsTable>, [<lFlag>] ) -> <lPreviousFlag>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<lFlag> a logical value indicating to turn on or off the 'case match' flag of the hash table
Returns
The previous value of the 'case match' flag
Description
This function is equivalent to HB_HSETCASEMATCH() but it returns the old flag value rather than the hash table
Example(s)
LOCAL hsTable, lFlag
hsTable := HB_HASH( "one", 1, "two", 2 )
// turn 'case match' on for a new hash table, storing ol flag
lFlag := HB_HCASEMATCH( hsTable, .T. )
Status
Ready
Compliance
This is Harbour specific
See also
HB_HSETCASEMATCH()
Index
API

HB_HCLONE()

Creates a copy of a hash table
Syntax
HB_HCLONE( <hsTable> ) -> <hsDestination>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
Returns
A cloned copy of the hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HCOPY()

Adds entries from the source hash table to the destination hash table
Syntax
HB_HCOPY( <hsDestination>, <hsSource>, [<nStart>], [<nCount>] ) -> <hsDestination>
Argument(s)
<hsDestination> a destination hash table, created by HB_HASH()
<hsSource> a source hash table, created by HB_HASH()
<nStart> starting index, defaults to 1 if omitted
<nCount> counter, defaults to (length) - <nStart> is omitted
Returns
The destination hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HDEFAULT()

Returns/sets a default value for a hash table.
Syntax
HB_HDEFAULT( <hsTable>, <DefaultValue> ) -> <OldDefaultValye>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<DefaultValue>
Returns
The previous default value assigned to the hash table
Status
Ready
Compliance
This is Harbour specific
See also
TODO: locate and list those methods that use this feature
Index
API

HB_HDEL()

Removes a key/value pair from a hash table
Syntax
HB_HDEL( <hsTable>, <Key> ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Key> key to be removed from the hash table; can be of type: number, date, datetime, string, pointer
Returns
The hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HDELAT()

Removes an entry from a hash table based on its index position
Syntax
HB_HDELAT( <hsTable>, <nPosition> ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<nPosition> the position of an entry within the hash table that will be deleted
Returns
The hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HEVAL()

Evaluate a code block across the contents of a hash table
Syntax
HB_HEVAL( <hsTable>, <bBlock>, [<nStart>], [<nCount>] ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<bBlock> code block to be evaluated
<nStart> starting index, defaults to 1 if omitted
<nCount> counter, defaults to (length) - <nStart> is omitted
Returns
The hash table
Description
The code block is evaluated for every hash table entry starting at <nStart> for <nCount> items.
The code block is passed the entry key, value, and numeric position
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HFILL()

Fills a hash table with a value
Syntax
HB_HFILL( <hsTable>, <Value> ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Value> fill value; can be of type: block, string, numeric, date/datetime, logical, nil, pointer, array, hash table
Returns
The hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HGET()

Returns a hash value
Syntax
HB_HGET( <hsTable>, <Key> ) -> <Value>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Key> key to be retrieve from the hash table; can be of type: number, date, datetime, string, pointer
Returns
Either the value within the hash table for the given key.
An array access error occurs of the key is not found
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HGETDEF()

Returns a hash value, or a default value if the key is not present
Syntax
HB_HGETDEF( <hsTable>, <Key>, [<DefaultValue>] ) -> <Value>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Key> key to be retrieve from the hash table; can be of type: number, date, datetime, string, pointer
<DefaultValue> a default value to be returned if the hash table does not contain the key
Returns
Either the value within the hash table for the given key, or the default value.
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HHASKEY()

Determines whether a hash table has an entry with a give key
Syntax
HB_HHASKEY( <hsTable>, <Key> ) -> lExists
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Key> a key value to be queried for; can be of type: number, date, datetime, string, pointer
Returns
A logical value indicating whether the key exists within the hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HKEYAT()

Gets a hash table key at a given position
Syntax
HB_HKEYAT( <hsTable>, <nPosition> ) -> <Key>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<nPosition> the position of an entry within the hash table that will be returned
Returns
The key at the given position of the hash table; the type will be one: number, date, datetime, string, pointer
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HKEYS()

Returns an array of the keys of a hash table
Syntax
HB_HKEYS( <hsTable> ) -> <aKeys>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
Returns
An array of all the hash table keys
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HMERGE()

Merges a source hash table into a destination hash table
Syntax
HB_HMERGE( <hsDestination>, <hsSource>, <bBlock>|<nPosition> ) -> <hsDestination>
Argument(s)
<hsDestination> a destination hash table, created by HB_HASH()
<hsSource> a source hash table, created by HB_HASH()
<bBlock> a code block that will be evaluated for each entry within the source hash table; the code block will be passed the entry key, value and position; if the code block returns a true value, the entry will be added to the destination hash table
<nPosition> the position of an entry within the source hash table that will be appended to the destination hash table
TODO: the source code passes either a number or HB_HASH_UNION; research this
Returns
The destination hash table with the contents of the source hash table merged
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HPAIRAT()

Returns a two-dimensional array of a hash table entry key/value pair
Syntax
HB_HPAIRAT( <hsTable>, <nPosition> ) -> <aKeyValue>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<nPosition> the position of an entry within the hash table that will be returned
Returns
A two-dimensional array of the key/value pair entry of the hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HPOS()

Locates the index of a key within a hash table
Syntax
HB_HPOS( <hsTable>, <Key> ) -> nPosition
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Key> key for which its position is to be determined; can be of type: number, date, datetime, string, pointer
Returns
A integer number being the index position of the key within the hash table.
TODO: what is the return value if the key does not exist? zero (0)? RTE?
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HSCAN()

Scans a hash table
Syntax
HB_HSCAN( <hsTable>, <Value>, [<nStart>], [<nCount>, [<lExact>] ) -> nPosition
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Value> to be located within the hash table
<nStart> starting index, defaults to 1 if omitted
<nCount> counter, defaults to (length) - <nStart> is omitted
<lExact> logical valuye indicating whether the comparision is to be be exact or not
Returns
The position of the located value within the hash table, or zero (0) if not found.
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HSET()

Sets a hash value
Syntax
HB_HSET( <hsTable>, <Key>, <Value> ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<Key> the key of the entry to be set; can be of type: number, date, datetime, string, pointer
<Value> the entry value
Returns
The hash table
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HSETAUTOADD()

Sets the 'auto add' flag for the hash table
Syntax
HB_HSETAUTOADD( <hsTable>, [<lFlag>] ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<lFlag> a logical value indicating to turn on or off the 'auto add' flag of the hash table
Returns
The hash table
Description
This function is equivalent to HB_HAUTOADD() but it returns the passed hash table rather than the old flag value
Example(s)
LOCAL hsTable
// turn 'auto add' on for a new hash table
hsTable := HB_HSETAUTOADD( HB_HASH( "one", 1, "two", 2 ), .T. )
Status
Ready
Compliance
This is Harbour specific
See also
HB_HAUTOADD(),HB_HSETBINARY(),HB_HSETCASEMATCH()
Index
API

HB_HSETBINARY()

Sets the 'binary' flag for the hash table
Syntax
HB_HSETBINARY( <hsTable>, [<lFlag>] ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<lFlag> a logical value indicating to turn on or off the 'binary' flag of the hash table
Returns
The hash table
Description
This function is equivalent to HB_HBINARY() but it returns the passed hash table rather than the old flag value
Example(s)
LOCAL hsTable
// turn 'binary' on for a new hash table
hsTable := HB_HSETBINARY( HB_HASH( "one", 1, "two", 2 ), .T. )
Status
Ready
Compliance
This is Harbour specific
See also
HB_HBINARY(),HB_HSETAUTOADD(),HB_HSETCASEMATCH
Index
API

HB_HSETCASEMATCH()

Sets the 'case match' flag for the hash table
Syntax
HB_HSETCASEMATCH( <hsTable>, [<lFlag>] ) -> <hsTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<lFlag> a logical value indicating to turn on or off the 'case match' flag of the hash table
Returns
The hash table
Description
This function is equivalent to HB_HCASEMATCH() but it returns the passed hash table rather than the old flag value
Example(s)
LOCAL hsTable
// turn 'case match' on for a new hash table
hsTable := HB_HSETCASEMATCH( HB_HASH( "one", 1, "two", 2 ), .T. )
Status
Ready
Compliance
This is Harbour specific
See also
HB_HCASEMATCH(),HB_HSETAUTOADD(),HB_HSETBINARY
Index
API

HB_HSORT()

Reorganizes the internal list of the hash table to be sorted
Syntax
HB_HSORT( <hsTable> ) -> <hsSortedTable>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
Returns
The hash table sorted
TODO: is the original table altered?
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HVALUEAT()

Gets/sets a hash value at a given position
Syntax
HB_HVALUEAT( <hsTable>, <nPosition>, [<NewValue>] ) -> <Value>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
<nPosition> the position of an entry within the hash table that will be returned
<NewValue> a new value to be assigned to the hash table at the given position
Returns
The existing value, or the new value if it is given
Status
Ready
Compliance
This is Harbour specific
Index
API

HB_HVALUES()

Returns an array of the values of a hash table
Syntax
HB_HVALUES( <hsTable> ) -> <aValues>
Argument(s)
<hsTable> a hash table, created by HB_HASH()
Returns
An array of all the hash values
Status
Ready
Compliance
This is Harbour specific
Index
API

Idle states

HB_IDLEADD()

Adds the background task.
Syntax
HB_IDLEADD( <bAction> ) --> nHandle
Argument(s)
<bAction> is a codeblock that will be executed during idle states. There are no arguments passed to this codeblock during evaluation.
Returns
<nHandle> The handle (an integer value) that identifies the task. This handle can be used for deleting the task.
Description
HB_IDLEADD() adds a passed codeblock to the list of background tasks that will be evaluated during the idle states. There is no limit for the number of tasks.
Example(s)
nTask := HB_IDLEADD( {|| SayTime() } )
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'Harbour extension similar to FT_ONIDLE() function available in NanForum library.'
Platform(s)
This is available on all platforms
File(s)
src/rtl/idle.c
See also
HB_IDLEDEL(),HB_IDLESTATE()
Index
API

HB_IDLEDEL()

Removes the background task from the list of tasks.
Syntax
HB_IDLEDEL( <nHandle> ) --> <bAction>
Argument(s)
<nHandle> is the identifier of the task returned by the HB_IDLEADD() function.
Returns
<bAction> NIL if invalid handle is passed or a codeblock that was passed to HB_IDLEADD() function
Description
HB_IDLEDEL() removes the action associated with passed identifier from the list of background tasks. The identifer should be the value returned by the previous call of HB_IDLEADD() function.
If specified task is defined then the codeblock is returned otherwise the NIL value is returned.
Example(s)
nTask := HB_IDLEADD( {|| SayTime() } )
INKEY(10)
bAction := HB_IDLEDEL( nTask )
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
src/rtl/idle.c
See also
HB_IDLEADD(),HB_IDLESTATE()
Index
API

HB_IdleState()

Evaluates a single background task and calls the garbage collector.
Syntax
HB_IDLESTATE()
Argument(s)
None
Description
HB_IDLESTATE() requests the garbage collection and executes a single background task defined by the codeblock passed with HB_IDLEADD() function. Every call to this function evaluates a different task in the order of task creation. There are no arguments passed during a codeblock evaluation.
This function can be safely called even if there are no background tasks defined.
Example(s)
nTask1 := HB_IDLEADD( {|| SayTime() } )
nTask2 := HB_IDLEADD( {|| SaveScreen() } )
DO WHILE( !bFinished )
bFinished := DOSomethingVeryImportant()
HB_IdleState()
ENDDO
cbAction := HB_IDLEDEL( nTask1 )
HB_IDLEDEL( nTask2 )
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'Harbour extension similar to FT_IAMIDLE() function available in NanForum library.'
Platform(s)
This is available on all platforms
File(s)
src/rtl/idle.c
See also
HB_IDLEADD(),HB_IDLEDEL()
Index
API

INET

HB_INETACCEPT

Wait until a socket is ready
Syntax
HB_INETACCEPT( <socket> ) -> SOCKET
Argument(s)
An INET socket
Returns
<socket> a socket previously created / opened
Description
Waits until a connection is available on a socket created with hb_InetServer, returns a socket that can be used to communicate with the incoming client.
On error, NIL is returned and error code sets in the passed SOCKET.
This error can be accessed using hb_InetErrorCode() function.
Compliance
This is Harbour specific
Index
API

HB_INETADDRESS

Get a remote server address
Syntax
HB_INETADDRESS( <socket> ) -> cResult
Argument(s)
<socket> a socket previously created / opened
Returns
Server address
Description
Returns a string representing the remote server address in quad dot notation, e.g. "192.168.1.1", or the local server address if the socket is server side.
TODO: have a version that returns a vector of 4 numbers.
Compliance
This is Harbour specific
Index
API

HB_INETCLEANUP

Terminate Harbour INET support
Syntax
HB_INETCLEANUP()
Argument(s)
(This function has no arguments)
Description
Closes inet support; mainly used for Windows. Put it at the end of any program using Inet functions, just before the program exits.
Compliance
This is Harbour specific
Index
API

HB_INETCLEARERROR

Clear the socket error value
Syntax
HB_INETCLEARERROR( <socket> )
Argument(s)
<socket> a socket previously created / opened
Compliance
This is Harbour specific
Index
API

HB_INETCLEARPERIODCALLBACK

Clear the periodic callback value of a socket
Syntax
HB_INETCLEARPERIODCALLBACK( <socket> )
Argument(s)
<socket> a socket previously created / opened
Compliance
This is Harbour specific
Index
API

HB_INETCLEARTIMELIMIT

Clear the time limit value of a socket
Syntax
HB_INETCLEARTIMELIMIT( <socket> )
Argument(s)
<socket> a socket previously created / opened
Description
Clears the default time limit of the given socket.
Compliance
This is Harbour specific
Index
API

HB_INETCLEARTIMEOUT

Clear the timeout value of a socket
Syntax
HB_INETCLEARTIMEOUT( <socket> )
Argument(s)
<socket> a socket previously created / opened
Description
Clears the default timeout of the given socket. Default timeout is used in all blocking operations.
Compliance
This is Harbour specific
Index
API

HB_INETCLOSE

Close an INET socket
Syntax
HB_INETCLOSE( <socket> ) -> nResult
Argument(s)
<socket> a socket previously created / opened
Returns
Returns 0 on success or -1 on error; on error, the error code is set; (actually, on success the socket error code is set to 1 -- socket closed )
Description
Closes the socket, notifiying both ends of the communication pipe that the connection is over.
If you have threads waiting for data to be read from this socket, this method will make them stop waiting and return an error (socket closed) to their callers.
The method does not destroy the socket, which can be used by subordinate threads to check that the socket is closed, and so they should stop as soon as they can. Don't destroy the socket unless you are sure that no other thread is using it.
Compliance
This is Harbour specific
Index
API

HB_INETCONNECTIP

Connect to a remote server by IP address
Syntax
HB_INETCONNECTIP( <cAddress>, <nPort> ) -> SOCKET
HB_INETCONNECTIP( <cAddress>, <nPort>, <socket> ) -> NIL
Argument(s)
<cAddress>
<nPort>
<socket>
Returns
(First form) INET socket
(Second form has no return value)
Description
Connects to a remote server described by cAddress, that can be specified only in quad dot IPV4 notation (e.g. "127.0.0.1"), using the desired port. This version of hb_InetConnect does not use gethostbyname, and thus is thread safe and can be used in combination with hb_InetGetHosts to have a finer timeout control while connecting to a server, and a finer error control.
The second version of this function accepts a pre-built socket as a parameter. This allows to kill asyncronously a thread waiting for hb_InetConnectIP to connect, and then cleaning up the leftover socket data. Also, it is possible to give timeout at the given SOCKET.
On error, the error of the returned socket is set.
Compliance
This is Harbour specific
Index
API

HB_INETCONNECT

Connect a socket to a remote server by IP address or name
Syntax
HB_INETCONNECT( <cAddress>, <nPort> ) -> SOCKET
HB_INETCONNECT( <cAddress>, <nPort>, <socket> ) -> NIL
Argument(s)
<cAddress>
<nPort>
<socket>
Returns
(First form) INET socket
(Second form has no return value)
Description
Connects to a remote server described by cAddress, that can be in quad dot notation (e.g. "192.168.1.1") or in DNS name (e.g. "www. xharbour.org"), using the desired port.
hb_InetConnect uses "gethostbyname" C system call to find the network address of the specified server; this means that this call is an hybrid function doing both a DNS scan and a TCP/IP connection. hb_InetConnect is not thread safe, and the program must take care that two hb_InetConnect functions are never called at the same moment from two different threads (or that hb_InetGetHosts is not called in the same moment as an hb_InetConnect).
The second version of this function accepts a pre-built socket as a parameter. This allows to kill asyncronously a thread waiting for hb_InetConnect to connect, and then cleaning up the leftover socket data. Also, it is possible to give timeout to the given SOCKET, but this timeout will be used only in the connection phase, after that the network address resolution is completed. Use GetHosts() and hb_InetConnectIP for a finer timeout control. On error, the error of the returned socket is set. The error could be due to unavailable name resolving service, host name not valid, host address not reachable and host reachable but port not open.
Compliance
This is Harbour specific
Index
API

HB_INETCOUNT

Get the number of bytes last read or sent
Syntax
HB_INETCOUNT( <socket> ) -> nResult
Argument(s)
<socket> a socket previously created / opened
Returns
Last socket operation character count
Description
Returns the amount of characters read or written in the latest socket operation.
Compliance
This is Harbour specific
Index
API

HB_INETCREATE

Create an INET socket
Syntax
HB_INETCREATE( [ <nTimeout> ] ) -> SOCKET
Argument(s)
<nTimeout> Socket timeout (optional) TODO: what is the scale (seconds, milliseconds?)
Returns
An INET socket
Description
Creates the raw data of the socket, that can be passed to a asynchronous connection function (hb_InetConnect or hb_InetConnectIP). This will prevent the connection function from allocating some data that could be never used in certain cases, i.e. an asynchronously detected timeout.
Compliance
This is Harbour specific
Index
API

HB_INETCRLF

Get a CRLF sequence for internet protocols
Syntax
HB_INETCRLF() -> cResult
Argument(s)
(This function has no arguments)
Returns
Internet CRLF sequence
Description
Returns a CRLF sequence used in many internet protocols.
Compliance
This is Harbour specific
Index
API

HB_INETDATAREADY

Get whether there is data ready in a socket
Syntax
HB_INETDATAREADY( <socket>, [ <nMillisec> ] ) -> nResult
Argument(s)
<socket> a socket previously created / opened
<nMillisec>
Returns
If there is data available 1 (one) is returned, 0 (zero) if there is no data and -1 if there is an error.
Description
Verifies if some data is available to be read in the socket without blocking execution of the caller.
If nMillisecs is not given, the function returns immediately 1 if there is some data to be read, 0 if there isn't any data and -1 in case of error.
If nMillisecs is given, the functon will wait up to that amount of milliseconds for data to be available; if some data arrives in the meanwhile, the wait is immediately interrupted.
The next hb_InetRecv() function will read all the available data (up to the required length) without blocking.
On error, hb_InetErrorCode and hb_InetErrorDesc can be use to determine what kind of error happened.
Compliance
This is Harbour specific
Index
API

HB_INETDGRAMBIND

Create a bound datagram socket
Syntax
HB_INETDGRAMBIND( <nPort>, [<cAddress> [, <lBroadcast>] ] ) -> SOCKET
Argument(s)
<nPort>
<cAddress>
<bBroadcast>
Returns
An INET socket
Description
Creates a datagram-oriented socket and binds it to a particular port, and eventually to a certain interface if cAddress is given and not NIL.
If lBroadcast is set to .T., the routine creates a broadcast capable socket: it will be able to receive and send broadcast messages. On most systems this requires special user privileges.
Returns the socket
If an error occurs, the socket error message and code are set.
Compliance
This is Harbour specific
Index
API

HB_INETDGRAMRECV

Get data from a datagram socket
Syntax
HB_INETDGRAMRECV( <socket>, @<cBuffer> [, <nSize> ] ) -> nBytesRead
Argument(s)
<socket> a socket previously created / opened
<cBuffer> is the target buffer and must be passed by reference
<nSize>
Returns
Returns number of bytes read, or -1 on error
Description
Reads at maximum nSize bytes incoming from a UDP socket, if nSize is given, or reads at maximum cBuffer length if nSize is not given.
There isn't any guarantee that all the data required to be read is really sent from the kernel to the application: the kernel should just return the last complete datagram that has been received, up to nSize bytes.
Compliance
This is Harbour specific
Index
API

HB_INETDGRAMSEND

Send data to a datagram socket
Syntax
HB_INETDGRAMSEND( <socket>, <cAddress>, <nPort>, <cBuffer> [, <nSize> ] ) -> nBytesSent
Argument(s)
<socket> a socket previously created / opened
<cAddress>
<nPort>
<cBuffer>
<nSize>
Returns
Returns number of bytes sent, or -1 on error
Description
Sends a datagram (a fixed length data) to a determined ip address (cAddress, to be specified in quad-dot notation) and port.
If nSize is not specified, all the data in cBuffer will be sent; if nSize is specified, only the first nSize bytes of cBuffer will be sent.
There isn't any guarantee that all the data required to be written is really sent to the socket: the calling program should check for the numeric return and send iteratively the unsent data to complete the message.
Anyway, the raw datagram is sent and received as once, and any data less than the system datagram size will be sent and received as a single item.
If the socket is created in broadcast mode, the cAddress element can be a broadcast address.
Returns -1 on error, or the number of bytes actually sent on success.
Compliance
This is Harbour specific
Index
API

HB_INETDGRAM

Create a datagram socket
Syntax
HB_INETDGRAM( [<lBroadcast>] ) -> SOCKET
Argument(s)
lBroadcast
Returns
An INET socket
Description
Creates a datagram-oriented socket that will be able to send data and eventually receive data. Since the socket is not bound, the program can't retrieve the address at which this socket appaers to be, but a second socket receiving a message sent from this one would be able to reply correctly with a datagram that can be read from a non-bound socket.
If lBroadcast is set to .T., the routine creates a broadcast capable socket: it will be able to receive and send broadcast messages. On most systems this requires special user privileges.
Returns the socket, and if an error occurs, the socket error message and code are set.
Compliance
This is Harbour specific
Index
API

HB_INETERRORCODE

Get the last INET error code
Syntax
HB_INETERRORCODE( <socket> ) -> nResult
Argument(s)
<socket> a socket previously created / opened
Returns
Last error code
Description
Returns the last error code that has been provoked by a network operation, or 0 if none.
Error codes are the ones used for winsock or UnixSockets (they are the same); 1 is reserved for "connection closed" message.
Compliance
This is Harbour specific
Index
API

HB_INETERRORDESC

Get the last INET error code description
Syntax
HB_INETERRORDESC( <socket> ) -> cResult
Argument(s)
<socket> a socket previously created / opened
Returns
System-dependant error string
Description
Returns a string describing the last error that occurred in the socket; the string is system dependent, and should be used only for debugging purposes.
Compliance
This is Harbour specific
Index
API

HB_INETFD

?
Syntax
HB_INETFD( <socket> [, <lNoSocket> ] ) -> nResult
Argument(s)
<socket> a socket previously created / opened
<lNoSocket>
Returns
?
Compliance
This is Harbour specific
Index
API

HB_INETGETALIAS

Get an array of aliases of a server
Syntax
HB_INETGETALIAS( <cName> ) -> aHosts
Argument(s)
<cName>
Returns
Array of server aliases
Description
Returns an array containing the aliases ( CNAME DNS records ) by which the server is currently known.
Whether this function is able to have the complete list of aliases or not depends on the verbosity of the DNS server.
Compliance
This is Harbour specific
Index
API

HB_INETGETHOSTS

Get an array of IP addresses of a host
Syntax
HB_INETGETHOSTS( <cName> ) -> aHosts
Argument(s)
<cName>
Returns
An array of IP addresses
Description
Returns an array containing all the IP addresses associated with a given host name. The IP addressess returned by this funtion are strings in quad dot notations, eg "192.168.1.1", and can be directly used into hb_InetConnectIP().
cName can be any string: valid DNS names (eg. "www.myserver.com"), locally available names (e.g. "localhost" or windows Network Neighborhood names), or even IP addresses in quad dot notation.
NOTE: This function is not thread safe (by design), and programmers must be sure not to use it at the same time in two different threads, or not to use it together with a hb_InetConnect(). If this kind of situation should ever arise, you are advised to use a thread MUTEX.
On error, and if the server can't be found, the function returns NIL.
Compliance
This is Harbour specific
Index
API

HB_INETGETRCVBUFSIZE

Get the socket receive buffer size
Syntax
HB_INETGETRCVBUFSIZE( <socket> ) -> nResult
Argument(s)
<socket> a socket previously created / opened
Returns
Returns the socket receive buffer size or -1 if the socket is closed or an error occurs
Description
Returns the socket receive buffer size or -1 if the socket is closed or an error occurs
Compliance
This is Harbour specific
Index
API

HB_INETGETSNDBUFSIZE

Get the socket send buffer size
Syntax
HB_INETGETSNDBUFSIZE( <socket> ) -> nResult
Argument(s)
<socket> a socket previously created / opened
Returns
Returns the socket send buffer size or -1 if the socket is closed or an error occurs
Description
Returns the socket send buffer size or -1 if the socket is closed or an error occurs
Compliance
This is Harbour specific
Index
API

HB_INETINIT

Activate Harbour INET support
Syntax
HB_INETINIT() -> lResult
Argument(s)
(This function has no arguments)
Returns
Returns .T. or .F. whether the internal INET system was successfully initialized
Description
Activates inet support; mainly used for winsock start up at the moment, but could be used in the future for many other purpose. Put it at the beginning of every program using INET functions.
Compliance
This is Harbour specific
Index
API

HB_INETISSOCKET

Get whether a variable is a socket
Syntax
HB_INETISSOCKET( <socket> ) -> lResult
Argument(s)
<socket> a socket previously created / opened
Returns
Returns whether the passed parameter is a socket
Compliance
This is Harbour specific
Index
API

HB_INETPERIODCALLBACK

Get or change the periodic callback value of a socket
Syntax
HB_INETPERIODCALLBACK( <socket> [, <xCallback> ] ) -> xPreviousCallback
Argument(s)
<socket> a socket previously created / opened
xCallback a new periodic callback
Returns
The previous periodic callback value
Description
Sets or returns the socket periodic callback value
xCallback can be one of: a codeblock, an array of (...), or a (symbol) TODO: describe these better
Compliance
This is Harbour specific
Index
API

HB_INETPORT

Get the port a socket is bound to.
Syntax
HB_INETPORT( <socket> ) -> cResult
Argument(s)
<socket> a socket previously created / opened
Returns
Port name the socket is bound to.
Description
Returns the port to which this socket is bound, or the remote port if this socket is connected with a remote host or client
Compliance
This is Harbour specific
Index
API

HB_INETRECVALL

Read from a socket without blocking
Syntax
HB_INETRECVALL( <socket>, @<cResult>, [ <nAmount> ] ) -> nResult
Argument(s)
<socket> a socket previously created / opened
<cResult> is the target buffer and must be passed by reference
<nAmount> is the upper limit of characters to be read from the socket. If not passed this defaults to the length of cResult
Returns
The number of the characters read from the socket. Might be less than nAmount on premature socket closing or on network error.
Description
This function works exactly as hb_InetRecv except that it blocks until nAmount bytes are read, if nAmount is given, or cString is filled for its whole length.
Compliance
This is Harbour specific
Index
API

HB_INETRECVLINE

Read a line from a socket
Syntax
HB_INETRECVLINE( <socket> [, @<nBytesRead>, [, <nMaxLength> [, <nBufSize> ]]] ) -> cResult
Argument(s)
<socket> a socket previously created / opened
<nBytesRead> must be passed by reference
<nMaxLength>
<nBufSize>
Returns
Line read
Description
Blocks the calling thread until a sequence CRLF is read from the socket. Incremental allocation and end-of-line checking are done in an efficient way.
If an error occurs, or if the stream is closed before a CRLF is read, the function returns nothing and sets the socket error.
The returned string does not contain the trailing CRLF sequence, so an empty line is effectively returned as an empty string.
If the nBytesRead parameter is given, it will contain the number of bytes read from the socket, including the CRLF sequence, so that in normal conditions, nResult will report a count equal to the length of the returned string plus 2. nBytesRead will be 0 if stream is closed before a CRLF sequence is read, and will be -1 on error.
An optional nMaxLength parameter can be given to allow a maximum character count before the data is returned anyway. If this number is reached before a CRLF sequence is encountered, nBytesRead will contain the value one.
Finally, a nBufSize parameter can be given. If not, memory allocation will be increased by discrete amounts of 80 bytes. The programmer can provide here a different allocation strategy (e.g. setting nBufSize equal to nMaxLength, memory for reading the line will be allocated only once, at the beginning of the function).
Compliance
This is Harbour specific
Index
API

HB_INETRECV

Read from a socket
Syntax
HB_INETRECV( <socket>, @<cResult>, [ <nAmount> ] ) -> nResult
Argument(s)
<socket> a socket previously created / opened
<cResult> is the target buffer and must be passed by reference
<nAmount> is the upper limit of characters to be read from the socket. If not passed this defaults to the length of cResult
Returns
The number of the characters read from the socket.
Description
Reads from the socket into a buffer.
The parameter cString must be preallocated so that it has enough space to receive the data. The routine will block the thread until some bytes are read from the socket, the socket is closed (either from the receiver or the sender side) or a network error occurs, whichever comes first. In the latter cases, an error is set, and only the characters received until premature end of communications are returned.
Notice that there is no guarantee that all the available bytes will be read before the function returns, in fact, hb_InetRecv returns as soon it is able to fill cString with one or more bytes. To block the current process until the whole cString is filled (or nAmount bytes are read), use the hb_InetRecvALL().
Compliance
This is Harbour specific
Index
API

HB_INETRECVENDBLOCK

Read a block from a socket
Syntax
HB_INETRECVENDBLOCK( <socket> [, <cBlock >[, @<nBytesRead> [, <nMaxLength> [, <nBufSize> ]]]] ) -> cResult
Argument(s)
<socket> a socket previously created / opened
<cBlock>
<nBytesRead>
<nMaxLength>
<nBufSize>
Returns
Block read
Description
This function operates exactly the same way as hb_InetRecvLine, but the "record termination" is customizable through the cBlock parameter. If not given, this parameter defaults to the CRLF sequence. Provided by: Marcelo Lombardo
Compliance
This is Harbour specific
Index
API

HB_INETSENDALL

Send data through a socket with blocking
Syntax
HB_INETSENDALL( <socket>, <cBuffer> [, <nLength> ] ) -> nResult
Argument(s)
<socket> a socket previously created / opened
<cBuffer>
<nLength>
Returns
The amount of data written, 0 (zero) if the socket is closed, or -1 on an error
Description
This function works exactly as hb_InetSend() but it ensures that all the data to be sent is written before returning.
Compliance
This is Harbour specific
Index
API

HB_INETSEND

Sent data through a socket
Syntax
HB_INETSEND( <socket>, <cBuffer> [, <nLength> ] ) -> nResult
Argument(s)
<socket> a socket previously created / opened
<cBuffer>
<nLength>
Returns
The amount of data written, 0 (zero) if the socket is closed, or -1 on an error
Description
Send data being stored in a string over the socket.
The nLength parameter can be given to allow writing only a part of the string.
There is no guarantee that all of cBuffer will be sent, as this is a decision that is up to the OS; this function does not take care to ensure that the data is really sent; check the returned number and send the part that has not been sent.
To ensure that all the data is sent before the function returns, use the hb_InetSendAll() function.
On error, the error in the socket is set.
Compliance
This is Harbour specific
Index
API

HB_INETSERVER

Create a socket bound to a port
Syntax
HB_INETSERVER( <port> [, <cBindAddr> [, <nListenLimit> ]] ) -> SOCKET
Argument(s)
<port>
<cBindAddr>
<nListenLimit> is an internal parameter and rarely needs to be passed, defaults to 10
Returns
An INET socket
Description
Creates a server that can accept connections from client on a certain port.
If the computer on which hb_InetServer is called has more than one logical interface (e.g. one network card, one loopback and one PPP address), cBindAddr can be specified to select only one of these interfaces to accept connections for this process. This is useful when a server is present on two networks, and the service is to be available only in one of them. Also, the same port on other addresses is left free to be used, so you can have different server programs running for different networks but managing the same service. For example, an FTP server available to the internal network could be radically different from an FTP server available for the internet.
nListenLimit is the number of incoming connections accepted by kernel before the kernel has the chance to report them to the application program. If the sockets receive nListenLimit connections before accepting them all, the nListenLimit + 1 connection will be notified to be "busy" by the kernel. The default value of 10 is enough for even a heavy duty server.
On error, sets error description in the newly returned socket.
Compliance
This is Harbour specific
Index
API

HB_INETSETRCVBUFSIZE

Set the receive buffer size of a socket
Syntax
HB_INETSETRCVBUFSIZE( <socket>, nSize ) -> nSize
Argument(s)
<socket> a socket previously created / opened
nSize
Returns
Returns the passed nSize or -1 on error
Description
Sets the receive buffer size of a socket
Compliance
This is Harbour specific
Index
API

HB_INETSETSNDBUFSIZE

Set the send buffer size of a socket
Syntax
HB_INETSETSNDBUFSIZE( <socket>, <nSize> ) -> nSize
Argument(s)
<socket> a socket previously created / opened
nSize
Returns
Returns the passed nSize or -1 on error
Description
Sets the send buffer size of a socket
Compliance
This is Harbour specific
Index
API

HB_INETSTATUS

Get the status of a socket
Syntax
HB_INETSTATUS( <socket> ) -> nResult
Argument(s)
<socket> a socket previously created / opened
Returns
Returns 1 (one) if the socket exists, -1 if it does not
Compliance
This is Harbour specific
Index
API

HB_INETTIMELIMIT

Get or change the time limit value of a socket
Syntax
HB_INETTIMELIMIT( <socket> [, <nTimeLimit> ) -> NIL
Argument(s)
<socket> a socket previously created / opened
<nTimeLimit>
Returns
Returns the previous time limit value of the socket
Description
Sets or changes the time limit value of the socket.
Compliance
This is Harbour specific
Index
API

HB_INETTIMEOUT

Get or change the timeout value of a socket
Syntax
HB_INETTIMEOUT( <socket> [, <nTimeout> ] ) -> nPreviousTimeout
Argument(s)
<socket> a socket previously created / opened
<nTimeout> is the new socket timeout value
Returns
Returns the previous timeout value of the socket
Description
Sets or changes the timeout value of the socket.
Compliance
This is Harbour specific
Index
API

Internal

CLIPINIT()

Initialize various Harbour sub-systems
Syntax
CLIPINIT() --> NIL
Argument(s)
none.
Returns
CLIPINIT() always return NIL.
Description
CLIPINIT() is one of the pre-defined INIT PROCEDURE and is executed at program startup. It declare an empty MEMVAR PUBLIC array called GetList that is going to be used by the Get system. It activates the default error handler, and (at least for the moment) calls the function that sets the default help key.
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'It is said that CLIPINIT() should not call the function that sets the default help key since CA-Cl*pper does it in some other place.'
Platform(s)
This is available on all platforms
See also
INIT PROCEDURE
Index
API

__MVDBGINFO()

This function returns the information about the variables for debugger
Syntax
__MVDBGINFO( <nScope> [, <nPosition> [, @<cVarName>] ] )
Argument(s)
<nScope> = the scope of variables for which an information is asked
Supported values (defined in hbmemvar.ch) HB_MV_PUBLIC HB_MV_PRIVATE (or any other value)
<nPosition> = the position of asked variable on the list of variables with specified scope - it should start from position 1 <cVarName> = the value is filled with a variable name if passed by reference and <nPosition> is specified
Returns
The return value depends on the number of arguments passed
Description
This function retrieves the information about memvar variables. It returns either the number of variables with given scope (when the first argument is passed only) or a value of variable identified by its position in the variables' list (when second argument is passed). It also returns the name of a variable if optional third argument is passed by reference.
If requested variable doesn't exist (requested position is greater then the number of defined variables) then NIL value is returned and variable name is set to "?"
The dynamic symbols table is used to find a PUBLIC variable then the PUBLIC variables are always sorted alphabetically. The PRIVATE variables are sorted in the creation order.
Note:
Due to dynamic nature of memvar variables there is no guarantee that successive calls to retrieve the value of <Nth> PUBLIC variable will return the value of the same variable.
Example(s)
#include <hbmemvar.ch>
LOCAL nCount, i, xValue, cName
nCount =_mvDBGINFO( HB_MV_PUBLIC )
FOR i:=1 TO nCount
xValue =__mvDBGINFO( HB_MV_PUBLIC, i, @cName )
? i, cName, xValue
NEXT
Test(s)
#include <hbmemvar.ch>
PROCEDURE MAIN()
? 'PUBLIC=', __mvDBGINFO( HB_MV_PUBLIC )
? 'PRIVATE=', __mvDBGINFO( HB_MV_PRIVATE )
PUBLIC cPublic:='cPublic in MAIN'
? 'PUBLIC=', __mvDBGINFO( HB_MV_PUBLIC )
? 'PRIVATE=', __mvDBGINFO( HB_MV_PRIVATE )
PRIVATE cPrivate:='cPrivate in MAIN'
? 'PUBLIC=', __mvDBGINFO( HB_MV_PUBLIC )
? 'PRIVATE=', __mvDBGINFO( HB_MV_PRIVATE )
CountMemvars()
? 'Back in Main'
? 'PUBLIC=', __mvDBGINFO( HB_MV_PUBLIC )
? 'PRIVATE=', __mvDBGINFO( HB_MV_PRIVATE )
RETURN
PROCEDURE CountMemvars()
LOCAL i, nCnt, xVal, cName
PUBLIC ccPublic:='ccPublic'
PRIVATE ccPrivate:='ccPrivate'
? 'In CountMemvars'
? 'PUBLIC=', __mvDBGINFO( HB_MV_PUBLIC )
? 'PRIVATE=', __mvDBGINFO( HB_MV_PRIVATE )
PRIVATE cPublic:='cPublic'
? 'PUBLIC=', __mvDBGINFO( HB_MV_PUBLIC )
? 'PRIVATE=', __mvDBGINFO( HB_MV_PRIVATE )
nCnt =__mvDBGINFO( HB_MV_PRIVATE ) +1
FOR i:=1 TO nCnt
xVal =__mvDBGINFO( HB_MV_PRIVATE, i, @cName )
? i, '=', cName, xVal
NEXT
nCnt =__mvDBGINFO( HB_MV_PUBLIC ) +1
FOR i:=1 TO nCnt
xVal =__mvDBGINFO( HB_MV_PUBLIC, i, @cName )
? i, '=', cName, xVal
NEXT
RETURN
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function should be called from the debugger only.'
File(s)
Library is vm
Index
API

__SetHelpK()

Set F1 as the default help key
Syntax
__SetHelpK()
Argument(s)
None.
Description
Set F1 to execute a function called HELP if such a function is linked into the program.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is vm
See also
__XHelp(),SET KEY,SETKEY()
Index
API

__TextRestore()

Restore console output settings as saved by __TextSave()
Syntax
__TextRestore()
Argument(s)
none.
Description
__TextRestore() is used in the preprocessing of the TEXT TO command to restore console output settings that were previously saved by __TextSave().
Status
Ready
Compliance
This is an undocumented CA-Cl*pper v5.2 function and is only visible if source was compiled with the HB_C52_UNDOC flag
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SET(),SET ALTERNATE,SET PRINTER,TEXT,__TextSave()
Index
API

__TextSave()

Redirect console output to printer or file and save old settings
Syntax
__TextSave( <cFile> )
Argument(s)
<cFile> is either "PRINTER" (note the uppercase) in which console output is SET to PRINTER, or a name of a text file with a default ". txt" extension, that is used to redirect console output.
Description
__TextSave() is used in the preprocessing of the TEXT TO command to redirect the console output while saving old settings that can be restored later by __TextRestore().
Status
Ready
Compliance
This is an undocumented CA-Cl*pper v5.2 function and is only visible if source was compiled with the HB_C52_UNDOC flag
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SET(),SET ALTERNATE,SET PRINTER,TEXT,__TextRestore()
Index
API

__XHELP()

Determines whether a Help() user defined function exists.
Syntax
__XHELP() --> <xValue>
Argument(s)
None
Returns
This function returns aleatory values.
Description
This is an internal undocumented CA-Cl*pper function, which will try to call the user defined function HELP() if it is defined in the current application. This is the default SetKey() handler for the F1 key.
Status
Ready
Compliance
This is an undocumented CA-Cl*pper v5.2 function and is only visible if source was compiled with the HB_C52_UNDOC flag
File(s)
Library is rtl
Index
API

Language and Nation

HB_LANGERRMSG()

Description of an error code using current language
Syntax
HB_LANGERRMSG( <nErrorCode> ) --> cErrorMessage
Argument(s)
<nErrorCode> is one of the generic error codes (EG_...) defined in include/error.ch
Returns
HB_LANGERRMSG() return the error message string represented by the code <nErrorCode>.
Description
This function return the error message associated with an error code using the current language selected.
Example(s)
#include "error.ch"
REQUEST HB_LANG_ES
FUNCTION Main()
// English: Argument error
? "English:", HB_LANGERRMSG( EG_ARG )
HB_LANGSELECT( "ES" )
// Spanish: Error de argumento
? "Spanish:", HB_LANGERRMSG( EG_ARG )
RETURN NIL
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
Library are rtl, lang Header is error.ch
See also
HB_LANGSELECT(),NATIONMSG()
Index
API

HB_LANGMESSAGE()

Returns international strings messages and errors
Syntax
HB_LANGMESSAGE( <nMsg> ) --> cMessage
Argument(s)
<nMsg> is the message number to get.
Returns
HB_LANGMESSAGE() return the text associated with the code <nMsg>.
Description
HB_LANGMESSAGE() is similar to NATIONMSG() but give access to the whole list of language messages: Day and month names, generic error messages, internal errors, and others...
Use the header file hblang.ch for a list of base values for <nMsg>.
Example(s)
#include "hblang.ch"
REQUEST HB_LANG_ES
FUNCTION Main()
// English: Monday
? "English:", HB_LANGMESSAGE( HB_LANG_ITEM_BASE_DAY + 1 )
HB_LANGSELECT( "ES" )
// Spanish: Lunes
? "Spanish:", HB_LANGMESSAGE( HB_LANG_ITEM_BASE_DAY + 1 )
RETURN NIL
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
Library are rtl, lang Header is hblang.ch
See also
HB_LANGSELECT(),NATIONMSG(),REQUEST
Index
API

HB_LANGNAME()

Return the name of the current language module in use
Syntax
HB_LANGNAME() --> cLangName
Argument(s)
None.
Returns
<cLangName> Name of the current language in use
Description
This function return the current name of the language module in use.
Example(s)
REQUEST HB_LANG_PT
REQUEST HB_LANG_RO
REQUEST HB_LANG_ES
FUNCTION Main()
HB_LANGSELECT( 'PT' )       // Default language is now Portuguese
? CDOW( DATE() )            //Segunda-feira
? 'Current language is ", HB_LANGNAME()             // Portuguese
? 'Old language id selected is ", HB_LANGSELECT()   // PT
HB_LANGSELECT( 'RO' )       // Default language is now Romanian
? CMONTH( DATE() )          // Mai
? 'Old language id selected is ",HB_LANGSELECT()    // RO
HB_LANGSELECT( 'ES' )       // Default language is now Spanish
? 'Current language is ",HB_LANGNAME()              // Spanish
? CMONTH( DATE() )          // Mayo
? CDOW( DATE() )            // Lunes
RETURN NIL
Test(s)
See tests/langapi.prg, tests/langmsg.prg
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
Library are rtl, lang
See also
HB_LANGSELECT(),NATIONMSG()
Index
API

HB_LANGSELECT()

Select a specific nation message module
Syntax
HB_LANGSELECT( [<cNewLang>] ) --> cOldLang
Argument(s)
<cNewLang> The optional ID of the country language module. Possible values for <cNewLang> are below as defined in the Lang library, sorted by language.

Language Codepage <cNewLang>
Bulgarian 866 BG866
Bulgarian ISO-8859-5 BGISO
Bulgarian Windows-1251 BGWIN
Basque 850 EU
Catalan 850 CA
Chinese Simplified 936 ZHGB
Chinese Traditional 950 ZHB5
Croatian 852 HR852
Croatian ISO-8859-2 HRISO
Czech 852 CS852
Czech ISO-8859-2 CSISO
Czech Kamenickych CSKAM
Czech Windows-1250 CSWIN
Dutch 437 NL
English 437 EN
Esperanto 850 EO
French 850 FR
Galician 850 GL
German 850 DE
German ANSI ANSI DEWIN
Greek 737 EL
Greek ANSI Windows-1253 ELWIN
Hebrew 862 HE862
Hebrew Windows-1255 HEWIN
Hungarian 852 HU852
Hungarian CWI-2 HUCWI
Hungarian ISO-8859-2 HUISO
Hungarian Windows-1250 HUWIN
Icelandic 850 IS850
Indonesian 437 ID
Italian 437 IT
Korean 949 KO
Lithuanian Windows-1257 LT
Polish 852 PL852
Polish ISO-8859-2 PLISO
Polish Mazowia PLMAZ
Polish Windows-1250 PLWIN
Portuguese 850 PT
Romanian 852 RO
Russian 866 RU866
Russian KOI-8 RUKOI8
Russian Windows-1251 RUWIN
Serbian 852 SR852
Serbian ISO-8859-2 SRISO
Serbian Windows-1251 SRWIN
Slovenian 437 SL437
Slovenian 852 SL852
Slovenian ISO-8859-2 SLISO
Slovenian Windows-1250 SLWIN
Spanish 850 ES
Spanish ANSI ANSI ESWIN
Turkish 857 TR857
Turkish Windows-1254 TRWIN

Returns
<cOldLang> The old language indentifier
Description
This function set a default language module for date/month names, internal warnigs, NatMsg messages and internal errors. When a Lang ID is selected all messages will be output with the current language selected until another one is selected or the program ends. The default language is English (cLang == "EN").
NOTE: You must REQUEST every language module you intend to use. For example: to use the Russian RU866 language you must add the following to your program: REQUEST HB_LANG_RU866
Example(s)
REQUEST HB_LANG_PT
REQUEST HB_LANG_RO
REQUEST HB_LANG_ES
FUNCTION Main()
HB_LANGSELECT( 'PT' )       // Default language is now Portuguese
? CDOW( DATE() )            // Segunda-feira
? 'Old language id selected is ", HB_LANGSELECT()   // PT
HB_LANGSELECT( 'RO' )       // Default language is now Romanian
? CMONTH( DATE() )          // Mai
? 'Old language id selected is ",HB_LANGSELECT()   // RO
HB_LANGSELECT( 'ES' )       // Default language is now Spanish
? CMONTH( DATE() )          // Mayo
? CDOW( DATE() )            // Lunes
RETURN NIL
Test(s)
See tests/langapi.prg, tests/langmsg.prg
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
Libraty are rtl, lang
See also
HB_LANGNAME(),HB_SETCODEPAGE(),NATIONMSG(),REQUEST
Index
API

HB_LANG_REQUEST()

Syntax
C Prototype (macro definition)
#include <hbapilng.h> HB_LANG_REQUEST( id ) --> <see HB_LANG_REQUEST_( id )>
Argument(s)
<id>
Returns
<see HB_LANG_REQUEST_( id )>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Header file is hbapilng.h
Index
API

HB_SETCODEPAGE()

Select the active code page by language ID
Syntax
HB_SETCODEPAGE( [<cNewLang>] ) --> cOldLang
Argument(s)
<cNewLang> The optional ID of the country language module. Possible values for <cNewLang> are below as defined in the Codepage library, sorted by language.

Language Codepage <cNewLang>
Bulgarian 866 BG866
Bulgarian ISO-8859-5 BGISO
Bulgarian MIK BGMIK
Bulgarian Windows-1251 BGWIN
Croatian 437 HR437
Croatian 852 HR852
Croatian Windows-1250 HR1250
Czech 852 CS852
Czech ISO-8859-2 CSISO
Czech KAM CSKAM
Czech Windoes-1250 CSWIN
English 437 EN
French 850 FR
German 850 DE
German ISO-8859-1 DEWIN
Greek 737 EL
Greek Windows-1253 ELWIN
Hungarian (ntxhu852) 852 HU852
Hungarian (sixhu852) 852 HU852S
Hungarian (ntxhu852) ISO-8859-2 HUISO
Hungarian (sixhu852) ISO-8859-2 HUISOS
Hungarian (ntxhu852) Windows-1250 HUWIN
Hungarian (sixhu852) Windows-1250 HUWINS
Italian 437 IT437
Italian 850 IT850
Italian ISO-8859-1b ITISB
Italian ISO-8859-1 ITISO
Lithuanian Windows-1257 LT
Polish 852 PL852
Polish ISO-8859-2 PLISO
Polish Mazowia PLMAZ
Polish Windows-1250 PLWIN
Portuguese 850 PT850
Portuguese ISO-8859-1 PTISO
Russian 866 RU866
Russian KOI-8 RUKOI8
Russian Windows-1251 RU1251
Serbian Windows-1251 SRWIN
Slovak 852 SK852
Slovak ISO-8859-2 SKISO
Slovak Kamenicky SKKAM
Slovak Windows-1250 SKWIN
Slovenian 437 SL437
Slovenian 852 SL852
Slovenian ISO-8859-2 SLISO
Slovenian Windows-1250 SLWIN
Spanish 850 ES
Spanish ISO-8859-1 ESWIN
Spanish Modern ISO-8859-1 ESMWIN
Swedish 850 SV850
Swedish (Clipper) 437 SVCLIP
Swedish ISO-8859-1 SVWIN
Turkish 857 TR857
Turkish Windows-1254 TRWIN
Ukrainian 866 UA866
Ukrainian KOI-8U UAKOI8
Ukrainian Windows-1251 UA1251

Returns
<cOldLang> The old language indentifier
Description
HB_SETCODEPAGE() set the active code page use by Harbour for sorting and comparing strings. The default code page use ASCII order (cLang == "EN").
NOTE: You must REQUEST every code page module you intend to use. For example: to use the Russian RU866 code page you must add the following to your program: REQUEST HB_CODEPAGE_RU866
Example(s)
REQUEST HB_CODEPAGE_HU852
FUNCTION Main()
LOCAL cTxt := CHR( 71 ) + " > " + CHR( 144 ) + " is"
? HB_SETCODEPAGE()               // EN
? cTxt, CHR( 71 ) > CHR( 144 )   // G >  is .F.
? HB_SETCODEPAGE( "HU852" )      // EN
? cTxt, CHR( 71 ) > CHR( 144 )   // G >  is .T.
? HB_SETCODEPAGE( "EN" )         // HU852
? cTxt, CHR( 71 ) > CHR( 144 )   // G >  is .F.
RETURN NIL
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is a Harbour Extension.'
Platform(s)
This is available on all platforms
File(s)
Libraty are rtl, codepage
See also
HB_LANGNAME(),HB_LANGSELECT(),HB_TRANSLATE(),NATIONMSG(),REQUEST
Index
API

HB_TRANSLATE()

Translate a string from one code page to the other
Syntax
HB_TRANSLATE( <cSrcText>, [<cPageFrom>], [<cPageTo>] ) --> cDstText
Argument(s)
<cSrcText> Is the source string to translate.
<cPageFrom> Is the optional character code page ID of the source string. If not specified, the default code page is used.
<cPageTo> Is the optional character code page ID of the destination string. If not specified, the default code page is used.
Returns
HB_TRANSLATE() return destination string converted from the source string.
Description
HB_TRANSLATE() try to convert a source string from one code page into the other. If a code page ID is not recognized, or not linked in, the default code page is used. HB_TRANSLATE() is used usually to convert between the Dos and the Windows code pages of the same language.
NOTE: If the source code page and target code page does not have the same number of characters, a translation can not be done and the destination string is a copy of the source string.
NOTE: You must REQUEST every code page module you intend to use. For example: to use the Russian RU866 code page you must add the following to your program: REQUEST HB_CODEPAGE_RU866
Example(s)
REQUEST HB_CODEPAGE_DE
REQUEST HB_CODEPAGE_DEWIN
FUNCTION Main()
LOCAL cTxt := "A" + CHR( 142 ) + "BC"
? "German 850  text:", cTxt
? "German ANSI text:", HB_TRANSLATE( cTxt, "DE", "DEWIN" )
RETURN NIL
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is a Harbour Extension.'
Platform(s)
This is available on all platforms
File(s)
Libraty are rtl, codepage
See also
HB_LANGSELECT(),HB_SETCODEPAGE(),NATIONMSG(),REQUEST
Index
API

ISAFFIRM()

Checks if passed char is an affirmation char
Syntax
ISAFFIRM( <cChar> ) --> <lTrueOrFalse>
Argument(s)
<cChar> is a char or string of chars
Returns
<lTrueOrFalse> True if passed char is an affirmation char, otherwise
false
Description
This function is used to check if a user's input is true or not
according to the msgxxx module used.
Example(s)
// Wait until user enters Y
DO WHILE !ISAFFIRM( cYesNo )
ACCEPT "Sure: " TO cYesNo
END DO
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
ISNEGATIVE(),NATIONMSG()
Index
API

ISNEGATIVE()

Checks if passed char is a negation char.
Syntax
ISNEGATIVE( <cChar> ) --> <lTrueOrFalse>
Argument(s)
<cChar> is a char or string of chars
Returns
<lTrueOrFalse> True if passed char is a negation char, otherwise
false.
Description
This function is used to check if a user's input is true or not
according to the msgxxx module used.
Example(s)
// Wait until user enters N
DO WHILE !ISNEGATIVE( cYesNo )
ACCEPT "Sure: " TO cYesNo
END DO
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
ISAFFIRM(),NATIONMSG()
Index
API

Language and Nation MSG()

Returns international strings messages.
Syntax
Language and Nation MSG( <nMsg> ) --> <cMessage>
Argument(s)
<nMsg> is the message number you want to get.
Returns
<cMessage> If <nMsg> is a valid message selector, returns the message. If <nMsg> is nil returns "Invalid Argument", and if <nMsg> is any
other type it returns an empty string.
Description
Language and Nation MSG() returns international message descriptions.
Example(s)
// Displays "Sure Y/N: "  and waits until user enters Y
// Y/N is the string for NATIONMSG( 12 ) with default natmsg module.
DO WHILE !ISAFFIRM( cYesNo )
ACCEPT "Sure " + NATIONMSG( 12 ) + ": " TO cYesNo
END DO
Status
Unknown 'STATUS' code: 'C'
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
ISAFFIRM(),ISNEGATIVE()
Index
API

hb_langDGetErrorDesc()

Syntax
C Prototype
#include <hbapilng.h> hb_langDGetErrorDesc( ULONG ulIndex ) --> ( char * )pszResult
Argument(s)
<ulIndex>
Returns
<pszResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langDGetItem()

Syntax
C Prototype
#include <hbapilng.h> hb_langDGetItem( int iIndex ) --> ( void * )pResult
Argument(s)
<iIndex>
Returns
<pResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langDeRegister()

Syntax
C Prototype
#include <hbapilng.h> hb_langDeRegister( char * pszID ) --> ( HB_BOOL )bResult
Argument(s)
<pszID>
Returns
<bResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langFind()

Syntax
C Prototype
#include <hbapilng.h> hb_langFind( char * pszID ) --> ( PHB_LANG )pResult
Argument(s)
<pszID>
Returns
<pResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langID()

Syntax
C Prototype
#include <hbapilng.h> hb_langID( void ) --> ( char * )pszResult
Returns
<pszResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langName()

Syntax
C Prototype
#include <hbapilng.h> hb_langName( void ) --> ( char * )pszResult
Returns
<pszResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langRegister()

Syntax
C Prototype
#include <hbapilng.h> hb_langRegister( PHB_LANG lang ) --> ( HB_BOOL )bResult
Argument(s)
<lang>
Returns
<bResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langSelect()

Syntax
C Prototype
#include <hbapilng.h> hb_langSelect( PHB_LANG lang ) --> ( PHB_LANG )pResult
Argument(s)
<lang>
Returns
<pResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

hb_langSelectID()

Syntax
C Prototype
#include <hbapilng.h> hb_langSelectID( char * pszID ) --> ( char * )pszResult
Argument(s)
<pszID>
Returns
<pszResult>
Status
Ready
Compliance
Not applicable
Platform(s)
This is available on all platforms
File(s)
Library is lang
Index
API

Macro

HB_SETMACRO()

Enable/disable the macro compiler runtime features.
Syntax
HB_SETMACRO( <nOption>, [<lOnOff>] ) --> <lOldSetting>
Argument(s)
<nOption> One of the HB_SM_* constants defined in set.ch.
<lOnOff> .T. to enable or .F. to disable a feature
Returns
HB_SETMACRO() return the old state of requested feature.
Description
This function enables or disables some features of the macro compiler. The Harbour is extending the macro features compared to an original set available in CA-Cl*pper. Enabling/disabling some of them allows to keep strict CA-Cl*pper compatibility.
Available features are: <b>HB_SM_HARBOUR</b> - enables harbour extensions:
operators: ++, --, +=, -=, *=, /=, ^= objects: assigments to an instance variable
<b>HB_SM_XBASE</b> - enables other Xbase++ dialects extensions:
expanding of expresions lists
<b>HB_SM_SHORTCUTS</b> - enables optimized evaluation of
logical operators (.and., .or.)
<b>HB_SM_PREPROC</b> - enables preprocessing of commands
This is meaningfull if Harbour is compiled with HB_MACRO_STATEMENTS flag
Example(s)
INIT PROCEDURE IWANTCLIPPER()
HB_SETMACRO( HB_SM_HARBOUR, .F. )
HB_SETMACRO( HB_SM_XBASE, .F. )
RETURN
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on all platforms
File(s)
Header file is set.ch Library is macro
See also
Macro compiler
Index
API

Math

ABS()

Return the absolute value of a number.
Syntax
ABS(<nNumber>) --> <nAbsNumber>
Argument(s)
<nNumber> Any number.
Returns
<nAbsNumber> The absolute numeric value.
Description
This function yields the absolute value of the numeric value or expression <nNumber>.
Example(s)
Proc Main()
Local nNumber:=50
Local nNumber1:=27
cls
qout(nNumber-nNumber1)
qout(nNumber1-nNumber)
qout(ABS(nNumber-nNumber1))
qout(ABSnNumber1-nNumber))
qout(ABS( -1 * 345))
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
Index
API

EXP()

Calculates the value of e raised to the passed power.
Syntax
EXP( <nNumber> ) --> <nValue>
Argument(s)
<nNumber> Any real number.
Returns
<nValue> The anti-logarithm of <nNumber>
Description
This function returns the value of e raised to the power of <nNumber>. It is the inverse of LOG().
Example(s)
? EXP(45)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
LOG()
Index
API

HB_MATHERBLOCK()

Set/Get math error handling codeblock
Syntax
HB_MATHERBLOCK ([<bNewBlock>]) --> <bOldBlock>
Argument(s)
<bNewBlock>
Returns
<bOldBlock> is the current error handler codeblock
Status
Ready
Platform(s)
This is available on all platforms
File(s)
Library is rtl
Index
API

HB_MATHERMODE()

Set/Get math error handling mode
Syntax
HB_MATHERMODE ([<nNewMode>]) --> <nOldMode>
Argument(s)
[<nNumber>] new math error handling mode, one of the following
constants, defined in hbmath.ch:
HB_MATH_ERRMODE_DEFAULT HB_MATH_ERRMODE_CDEFAULT HB_MATH_ERRMODE_USER HB_MATH_ERRMODE_USERDEFAULT HB_MATH_ERRMODE_USERCDEFAULT
Returns
<nOldMode> old math error handling mode
Status
Ready
Platform(s)
This is available on all platforms
File(s)
Header file is hbmath.ch Library is rtl
Index
API

INT()

Return the integer port of a numeric value.
Syntax
INT( <nNumber> ) --> <nIntNumber>
Argument(s)
<nNumber> Any numeric value.
Returns
<nIntNumber> The integer portion of the numeric value.
Description
This function converts a numeric expression to an integer. All decimal digits are truncated. This function does not round a value upward or downward; it merely truncates a number at the decimal point.
Example(s)
SET Decimal to 5
? INT(632512.62541)
? INT(845414111.91440)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ROUND(),STRZERO()
Index
API

LOG()

Returns the natural logarithm of a number.
Syntax
LOG( <nNumber> ) --> <nLog>
Argument(s)
<nNumber> Any numeric expression.
Returns
<nExponent> The natural logarithm of <nNumber>.
Description
This function returns the natural logarithm of the number <nNumber>. If <nNumber> is 0 or less than 0, a numeric overflow occurs, which is depicted on the display device as a series of asterisks. This function is the inverse of EXP().
Example(s)
? LOG(632512)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
EXP()
Index
API

MAX()

Returns the maximum of two numbers or dates.
Syntax
MAX(<xValue>,<xValue1>) --> <xMax>
Argument(s)
<xValue> Any date or numeric value.
<xValue1> Any date or numeric value (same type as <xValue>).
Returns
<xMax> The larger numeric (or later date) value.
Description
This function returns the larger of the two passed espressions. If <xValue> and <xValue1> are numeric data types, the value returned by this function will be a numeric data type as well and will be the larger of the two numbers passed to it. If <xValue> and <xValue1> are date data types, the return value will be a date data type as well. It will be the later of the two dates passed to it.
Example(s)
? MAX(214514214,6251242142)
? MAX(CTOD('11/11/2000'),CTOD('21/06/2014')
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
Min()
Index
API

MIN()

Determines the minumum of two numbers or dates.
Syntax
MIN(<xValue>,<xValue1>) --> <xMin>
Argument(s)
<xValue> Any date or numeric value.
<xValue1> Any date or numeric value.
Returns
<xMin> The smaller numeric (or earlier date) value.
Description
This function returns the smaller of the two passed espressions. <xValue> and <xValue1> must be the same data type. If numeric, the smaller number is returned. If dates, the earlier date is returned.
Example(s)
? MIN(214514214,6251242142)
? MIN(CTOD('11/11/2000'),CTOD('21/06/2014')
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
MAX()
Index
API

MOD()

Return the modulus of two numbers.
Syntax
MOD( <nNumber>,<nNumber1>) --> <nRemainder>
Argument(s)
<nNumber> Numerator in a divisional expression.
<nNumber1> Denominator in a divisional expression.
Returns
<nRemainder> The remainder after the division operation.
Description
This functuion returns the remainder of one number divided by another.
Example(s)
? MOD(12,8.521)
? Mod(12,0)
? Mod(62412.5142,4522114.12014)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
%
Index
API

ROUND()

Rounds off a numeric expression.
Syntax
ROUND( <nNumber>,<nPlace> ) --> <nResult>
Argument(s)
<nNumber> Any numeric value.
<nPlace> The number of places to round to.
Returns
<nResult> The rounded number.
Description
This function rounds off the value of <nNumber> to the number of decimal places specified by <nPlace>. If the value of <nPlace> is a negative number, the function will attempt to round <nNumber> in whole numbers. Numbers from 5 through 9 will be rounded up, all others will be rounded down.
Example(s)
? ROUND(632512.62541,5)
? ROUND(845414111.91440,3)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
INT(),STR(),VAL(),SET FIXED
Index
API

SQRT()

Calculates the square root of a number.
Syntax
SQRT( <nNumber> ) --> <nSqrt>
Argument(s)
<nNumber> Any numeric value.
Returns
<nSqrt> The square root of <number>.
Description
This function returns the square root of <nNumber>. The precision of this evaluation is based solely on the settings of the SET DECIMAL TO command. Any negative number passed as <nNumber> will always return a 0.
Example(s)
SET Decimal to 5
? SQRT(632512.62541)
? SQRT(845414111.91440)
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ROUND()
Index
API

Objects

__ObjSetValueList()

Set object with an array of DATA names and values
Syntax
__ObjSetValueList( <oObject>, <aData> ) --> oObject
Argument(s)
<oObject> is an object to set.
<aData> is a 2D array with a pair of instance variables and values for setting those variable.
Returns
__ObjSetValueList() return a reference to <oObject>.
Description
__ObjSetValueList() is a low level class support function that let you set a group of instance variables with values. each array element in <aData> is a pair of: aData[ i, HB_OO_DATA_SYMBOL ] which contain the variable name to set aData[ i, HB_OO_DATA_VALUE ] contain the new variable value.
Example(s)
// set some TBrowse instance variable
oB := TBrowse():New()
aData := array( 4, 2 )
aData[ 1, HB_OO_DATA_SYMBOL ] = "nTop"
aData[ 1, HB_OO_DATA_VALUE  ] = 1
aData[ 2, HB_OO_DATA_SYMBOL ] = "nLeft"
aData[ 2, HB_OO_DATA_VALUE  ] = 10
aData[ 3, HB_OO_DATA_SYMBOL ] = "nBottom"
aData[ 3, HB_OO_DATA_VALUE  ] = 20
aData[ 4, HB_OO_DATA_SYMBOL ] = "nRight"
aData[ 4, HB_OO_DATA_VALUE  ] = 70
__ObjSetValueList( oB, aData )
? oB:nTop      // 1
? oB:nLeft     // 10
? oB:nBottom   // 20
? oB:nRight    // 70
Status
Ready
Compliance
This is Harbour specific
File(s)
Header file is hboo.ch Library is rtl
See also
__ObjGetValueList()
Index
API

__objAddData()

Add a DATA to an already existing class
Syntax
__objAddData( <oObject>, <cDataName> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cDataName> is the symbol name of the new DATA to add.
Returns
__objAddData() return a reference to <oObject>.
Description
__objAddData() is a low level class support function that add a new DATA to an object. <oObject> is unchanged if a symbol with the name <cDataName> already exist in <oObject>.
Example(s)
// create a new THappy class and add a lHappy DATA
oHappy  := HBClass():New( "THappy" )
__objAddData( oHappy, "lHappy" )
oHappy:lHappy := .T.
IF oHappy:lHappy
? "Happy, Happy, Joy, Joy !!!"
ELSE
? ":(..."
ENDIF
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddInline(),__objAddMethod(),__objDelData(),__objGetMsgList(), __ObjGetValueList(),__objHasData(),__ObjSetValueList()
Index
API

__objAddInline()

Add an INLINE to an already existing class
Syntax
__objAddInline( <oObject>, <cInlineName>, <bInline> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cInlineName> is the symbol name of the new INLINE to add.
<bInline> is a code block to associate with the INLINE method.
Returns
__objAddInline() return a reference to <oObject>.
Description
__objAddInline() is a low level class support function that add a new INLINE method to an object. <oObject> is unchanged if a symbol with the name <cInlineName> already exist in <oObject>.
Example(s)
// create a new THappy class and add a Smile INLINE method
oHappy  := HBClass():New( "THappy" )
bInline := { | nType | { ":)", ";)", "*SMILE*" }[ nType ] }
__objAddInline( oHappy, "Smile", bInline )
? oHappy:Smile( 1 )       // :)
? oHappy:Smile( 2 )       // ;)
? oHappy:Smile( 3 )       // *SMILE*
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddData(),__objAddMethod(),__objDelInline(),__ObjGetMethodList(), __objGetMsgList(),__objHasMethod() ,__objModInline()
Index
API

__objAddMethod()

Add a METHOD to an already existing class
Syntax
__objAddMethod( <oObject>, <cMethodName>, <nFuncPtr> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cMethodName> is the symbol name of the new METHOD to add.
<nFuncPtr> is a pointer to a function to associate with the method.
Returns
__objAddMethod() return a reference to <oObject>.
Description
__objAddMethod() is a low level class support function that add a new METHOD to an object. <oObject> is unchanged if a symbol with the name <cMethodName> already exist in <oObject>.
Note that <nFuncPtr> is a special pointer to a function that was created using the @ operator, see example below.
Example(s)
// create a new THappy class and add a Smile method
oHappy := HBClass():New( "THappy" )
__objAddMethod( oHappy, "Smile", @MySmile() )
? oHappy:Smile( 1 )       // :)
? oHappy:Smile( 2 )       // ;)
? oHappy:Smile( 3 )       // *SMILE*
STATIC FUNCTION MySmile( nType )
LOCAL cSmile
DO CASE
CASE nType == 1
cSmile := ":)"
CASE nType == 2
cSmile := ";)"
CASE nType == 3
cSmile := "*SMILE*"
ENDCASE
RETURN cSmile
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddInline(),__objAddData(),__objDelMethod(),__ObjGetMethodList(), __objGetMsgList(),__objHasMethod(),__objModMethod()
Index
API

__objDelData()

Delete a DATA (instance variable) from class
Syntax
__objDelMethod( <oObject>, <cDataName> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cDataName> is the symbol name of DATA to be deleted (removed) from the object.
Returns
__objDelData() return a reference to <oObject>.
Description
__objDelData() is a low level class support function that delete (remove) a DATA from an object. <oObject> is unchanged if a symbol with the name <cDataName> does not exist in <oObject>.
Example(s)
// create a new THappy class and add a lHappy DATA
oHappy  := HBClass():New( "THappy" )
__objAddData( oHappy, "lHappy" )
? __objHasData( oHappy, "lHappy" )    // .T.
// remove lHappy DATA
__objDelData( oHappy, "lHappy" )
? __objHasData( oHappy, "lHappy" )    // .F.
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddData(),__objGetMsgList(),__ObjGetValueList(),__objHasData(), __ObjSetValueList()
Index
API

__objDelInline()

Delete a METHOD INLINE from class
Syntax
__objDelInline( <oObject>, <cSymbol> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cSymbol> is the symbol name of METHOD or INLINE method to be deleted (removed) from the object.
Returns
__objDelInMethod() return a reference to <oObject>.
Description
__objDelInMethod() is a low level class support function that delete (remove) a METHOD or an INLINE method from an object. <oObject> is unchanged if a symbol with the name <cSymbol> does not exist in <oObject>.
Example(s)
// create a new THappy class and add a Smile method
oHappy := HBClass():New( "THappy" )
__objAddMethod( oHappy, "Smile", @MySmile() )
? __objHasMethod( oHappy, "Smile" )    // .T.
// remove Smile method
__objDelInMethod( oHappy, "Smile" )
? __objHasMethod( oHappy, "Smile" )    // .F.
STATIC FUNCTION MySmile( nType )
LOCAL cSmile
DO CASE
CASE nType == 1
cSmile := ":)"
CASE nType == 2
cSmile := ";)"
ENDCASE
RETURN cSmile
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddInline(),__objAddMethod(),__ObjGetMethodList(), __objGetMsgList(),__objHasMethod(),__objModInline(),__objModMethod()
Index
API

__objDelMethod()

Delete a METHOD from class
Syntax
__objDelMethod( <oObject>, <cSymbol> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cSymbol> is the symbol name of METHOD or INLINE method to be deleted (removed) from the object.
Returns
__objDelMethod() return a reference to <oObject>.
Description
__objDelMethod() is a low level class support function that deletes (removes) a METHOD or an INLINE method from an object. <oObject> is unchanged if a symbol with the name <cSymbol> does not exist in <oObject>.
__objDelInline() is exactly the same as __objDelMethod().
Example(s)
// create a new THappy class and add a Smile method
oHappy := HBClass():New( "THappy" )
__objAddMethod( oHappy, "Smile", @MySmile() )
? __objHasMethod( oHappy, "Smile" )    // .T.
// remove Smile method
__objDelMethod( oHappy, "Smile" )
? __objHasMethod( oHappy, "Smile" )    // .F.
STATIC FUNCTION MySmile( nType )
LOCAL cSmile
DO CASE
CASE nType == 1
cSmile := ":)"
CASE nType == 2
cSmile := ";)"
ENDCASE
RETURN cSmile
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddInline(),__objAddMethod(),__ObjGetMethodList(), __objGetMsgList(),__objHasMethod(),__objModInline(),__objModMethod()
Index
API

__objDerivedFrom()

Determine whether a class is derived from another class
Syntax
__objDerivedFrom( <oObject>, <xSuper> ) --> lIsParent
Argument(s)
<oObject> is the object to check.
<xSuper> is the object that may be a parent. <xSuper> can be either an Object or a Character string with the class name.
Returns
__objDerivedFrom() return a logical TRUE (.T.) if <oObject> is derived from <xSuper>.
Description
__objDerivedFrom() is a low level class support function that check is one class is a super class of the other, or in other words, does class <oObject> a child or descendant of <xSuper>.
Example(s)
// Create three classes and check their relations
#include "hbclass.ch"
FUNCTION main()
local oSuper, oObject, oDress
oSuper  := TMood():New()
oObject := THappy():New()
oDress  := TShirt():New()
? __objDerivedFrom( oObject, oSuper )    // .T.
? __objDerivedFrom( oSuper, oObject )    // .F.
? __objDerivedFrom( oObject, oDress )    // .F.
RETURN NIL
CLASS TMood
METHOD New() INLINE Self
ENDCLASS
CLASS THappy FROM TMood
METHOD Smile() INLINE qout( "*smile*" )
ENDCLASS
CLASS TShirt
DATA Color
DATA Size
METHOD New() INLINE Self
ENDCLASS
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objHasData(),__ObjHasMethod()
Index
API

__objGetMethodList()

Return names of all METHOD for a given object
Syntax
__objGetMethodList( <oObject> ) --> aMethodNames
Argument(s)
<oObject> is an object to scan.
Returns
__objGetMethodList() return an array of character stings with all METHOD names for a given object. __objGetMethodList() would return an empty array {} if the given object does not contain any METHOD.
Description
__objGetMethodList() is a low level class support function that let you find all class functions names for a given object. It is equivalent to __objGetMsgList( oObject, .F. ).
Example(s)
// show information about TBrowse class
oB := TBrowseNew( 0, 0, 24, 79 )
aMethod := __objGetMethodList( oB )
FOR i = 1 to len ( aMethod )
? "METHOD name:", aMethod[ i ]
NEXT
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objGetMsgList(),__ObjGetValueList(),__objHasData(),__objHasMethod()
Index
API

__objGetMsgList()

Return names of all DATA or METHOD for a given object
Syntax
__objGetMsgList( <oObject>, [<lData>], [nClassType] ) --> aNames
Argument(s)
<oObject> is an object to scan.
<lData> is an optional logical value that specifies the information to return. A value of .T. instruct the function to return list of all DATA names, .F. return list of all METHOD names. Default value is .T.
<nClassType> is on optional numeric code for selecting which class type to return. Default value is HB_MSGLISTALL, returning the whole list.
Returns
__objGetMsgList() return an array of character stings with all DATA names or all METHOD names for a given object. __objGetMsgList() would return an empty array {} if the given object does not contain the requested information.
Description
__objGetMsgList() is a low level class support function that let you find all instance variable or method names for a given object.
If specified, the following table shows the values for <nClassType> that allow you to distinguish between DATA and CLASSDATA:

hboo.ch Value Meaning
HB_MSGLISTALL 0 All types
HB_MSGLISTCLASS 1 CLASSDATA only
HB_MSGLISTPURE 2 DATA only

DATA are instance variable usable within each object from a class, where each object has its own DATAs.
CLASSDATA are shared by all objects from a Class, so the changed value within Object1 will be reflected when accessing the CLASSDATA from Object2.
Example(s)
// show information about TBrowse class
oB := TBrowseNew( 0, 0, 24, 79 )
aData      := __objGetMsgList( oB, .T. )
aClassData := __objGetMsgList( oB, .T., HB_MSGLISTCLASS )
aMethod    := __objGetMsgList( oB, .F. )
FOR i = 1 to len ( aData )
? "DATA name:", aData[ i ]
NEXT
FOR i = 1 to len ( aClassData )
? "CLASSDATA name:", aClassData[ i ]
NEXT
FOR i = 1 to len ( aMethod )
? "METHOD name:", aMethod[ i ]
NEXT
Status
Ready
Compliance
This is Harbour specific
File(s)
Header file is hboo.ch Library is rtl
See also
__ObjGetMethodList(),__ObjGetValueList(),__objHasData(), __objHasMethod()
Index
API

__objGetValueList()

Return an array of DATA names and values for a given object
Syntax
__objGetValueList( <oObject>, [<aExcept>] ) --> aData
Argument(s)
<oObject> is an object to scan.
<aExcept> is an optional array with DATA names you want to exclude from the scan.
Returns
__objGetValueList() return a 2D array that contain pairs of a DATA symbol name and the value of DATA. __objGetValueList() would return an empty array {} if the given object does not contain the requested information.
Description
__objGetValueList() is a low level class support function that return an array with DATA names and value, each array element is a pair of: aData[ i, HB_OO_DATA_SYMBOL ] contain the symbol name
aData[ i, HB_OO_DATA_VALUE ] contain the value of DATA
Example(s)
// show information about TBrowse class
oB := TBrowseNew( 0, 0, 24, 79 )
aData := __objGetValueList( oB )
FOR i = 1 to len ( aData )
? "DATA name:", aData[ i, HB_OO_DATA_SYMBOL ], ;
"    value=", aData[ i, HB_OO_DATA_VALUE  ]
NEXT
Status
Ready
Compliance
This is Harbour specific
File(s)
Header file is hboo.ch Library is rtl
See also
__objGetMethodList(),__objGetMsgList(),__objHasData(), __objHasMethod(),__ObjSetValueList()
Index
API

__objHasData()

Determine whether a symbol exist in object as DATA
Syntax
__objHasData( <oObject>, <cSymbol> ) --> lExist
Argument(s)
<oObject> is an object to scan.
<cSymbol> is the name of the symbol to look for.
Returns
__objHasData() return .T. if the given <cSymbol> exist as DATA (instance variable) in object <oObject), .F. if it does not exist.
Description
__objHasData() is a low level class support function that let you find out if a symbol is an instance variable in a given object.
Example(s)
oB := TBrowseNew( 0, 0, 24, 79 )
? __objHasData( oB, "nLeft" )      // this should return .T.
? __objHasData( oB, "lBugFree" )   // hopefully this should be .F.
? __objHasData( oB, "Left" )       // .F. since this is a METHOD
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__ObjGetMethodList(),__objGetMsgList(),__objHasMethod()
Index
API

__objHasMethod()

Determine whether a symbol exist in object as METHOD
Syntax
__objHasMethod( <oObject>, <cSymbol> ) --> lExist
Argument(s)
<oObject> is an object to scan.
<cSymbol> is the name of the symbol to look for.
Returns
__objHasMethod() return .T. if the given <cSymbol> exist as METHOD (class function) in object <oObject), .F. if it does not exist.
Description
__objHasMethod() is a low level class support function that let you find out if a symbol is a class function in a given object.
Example(s)
oB := TBrowseNew( 0, 0, 24, 79 )
? __objHasMethod( oB, "nLeft" )      // .F. since this is a DATA
? __objHasMethod( oB, "FixBugs" )    // hopefully this should be .F.
? __objHasMethod( oB, "Left" )       // this should return .T.
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__ObjGetMethodList(),__objGetMsgList(),__objHasData()
Index
API

__objModInline()

Modify (replace) an INLINE method in an already existing class
Syntax
__objModInline( <oObject>, <cInlineName>, <bInline> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cInlineName> is the symbol name of the INLINE method to modify.
<bInline> is a new code block to associate with the INLINE method.
Returns
__objModInline() return a reference to <oObject>.
Description
__objModInline() is a low level class support function that modify an INLINE method in an object and replace it with a new code block. <oObject> is unchanged if a symbol with the name <cInlineName> does not exist in <oObject>. __objModInline() is used in inheritance mechanism.
Example(s)
// create a new THappy class and add a Smile INLINE method
oHappy  := HBClass():New( "THappy" )
bMyInline   := { | nType | { ":)", ";)" }[ nType ] }
bYourInline := { | nType | { "*SMILE*", "*WINK*" }[ nType ] }
__objAddInline( oHappy, "Smile", bMyInline )
? oHappy:Smile( 1 )       // :)
? oHappy:Smile( 2 )       // ;)
// replace Smile inline method with a new code block
__objModInline( oHappy, "Smile", bYourInline )
? oHappy:Smile( 1 )       // *SMILE*
? oHappy:Smile( 2 )       // *WINK*
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddInline(),__objDelInline(),__ObjGetMethodList(), __objGetMsgList(),__objHasMethod()
Index
API

__objModMethod()

Modify (replace) a METHOD in an already existing class
Syntax
__objModMethod( <oObject>, <cMethodName>, <nFuncPtr> ) --> oObject
Argument(s)
<oObject> is the object to work on.
<cMethodName> is the symbol name of the METHOD to modify.
<nFuncPtr> is a pointer to a new function to associate with the method.
Returns
__objModMethod() return a reference to <oObject>.
Description
__objModMethod() is a low level class support function that modify a METHOD in an object and replace it with a new function. <oObject> is unchanged if a symbol with the name <cMethodName> does not exist in <oObject>. __objModMethod() is used in inheritance mechanism.
Note that <nFuncPtr> is a special pointer to a function that was created using the @ operator, see example below.
Example(s)
// create a new THappy class and add a Smile method
oHappy := HBClass():New( "THappy" )
__objAddMethod( oHappy, "Smile", @MySmile() )
? oHappy:Smile( 1 )       // :)
? oHappy:Smile( 2 )       // ;)
// replace Smile method with a new function
__objAddMethod( oHappy, "Smile", @YourSmile() )
? oHappy:Smile( 1 )       // *SMILE*
? oHappy:Smile( 2 )       // *WINK*
STATIC FUNCTION MySmile( nType )
LOCAL cSmile
DO CASE
CASE nType == 1
cSmile := ":)"
CASE nType == 2
cSmile := ";)"
ENDCASE
RETURN cSmile
STATIC FUNCTION YourSmile( nType )
LOCAL cSmile
DO CASE
CASE nType == 1
cSmile := "*SMILE*"
CASE nType == 2
cSmile := "*WINK*"
ENDCASE
RETURN cSmile
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
__objAddMethod(),__objDelMethod(),__ObjGetMethodList(), __objGetMsgList(),__objHasMethod()
Index
API

RDD

FIELDBLOCK()

Return a code block that sets/gets a value for a given field
Syntax
FIELDBLOCK( <cFieldName> ) --> bFieldBlock
Argument(s)
<cFieldName> is a string that contain the field name.
Returns
FIELDBLOCK() return a code block that when evaluate could retrieve a field value or assigning a new value to the field. If <cFieldName> is not specified or from type other than character, FIELDBLOCK() return NIL.
Description
FIELDBLOCK() return a code block that sets/gets the value of field. When this code block is evaluated without any parameters passed then it returns the current value of the given field. If the code block is evaluated with a parameter, than its value is used to set a new value to the field, this value is also return by the block. If the block is evaluate and there is no field with the name <cFieldName> in the current work area, the code block return NIL.
Note that FIELDBLOCK() works on the current work area, if you need a specific work area code block use FIELDWBLOCK() instead.
Example(s)
// open a file named Test that have a field named "name"
LOCAL bField
bFiled := FIELDBLOCK( "name" )
USE Test
? 'Original value of field "name" :', EVAL( bField )
EVAL( bField, "Mr X new name" )
? 'New value for the field "name" :', EVAL( bField )
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'If the block is evaluate and there is no field with the name <cFieldName> in the current work area, the code block return NIL.
CA-Cl*pper would raise BASE/1003 error if the field does not exist.'
File(s)
Library is rtl
See also
EVAL(),FIELDWBLOCK(),MEMVARBLOCK()
Index
API

FIELDWBLOCK()

Return a sets/gets code block for field in a given work area
Syntax
FIELDWBLOCK( <cFieldName>, <nWorkArea> ) --> bFieldBlock
Argument(s)
<cFieldName> is a string that contain the field name.
<nWorkArea> is the work area number in which <cFieldName> exist.
Returns
FIELDWBLOCK() return a code block that when evaluate could retrieve field value or assigning a new value for a field in a given work area. If <cFieldName> is not specified or from type other than character, or if <nWorkArea> is not specified or is not numeric FIELDWBLOCK() return NIL.
Description
FIELDWBLOCK() return a code block that sets/gets the value of field from a given work area. When this code block is evaluated without any parameters passed then it returns the current value of the given field. If the code block is evaluated with a parameter, than its value is used to set a new value to the field, this value is also return by the block. If the block is evaluate and there is no field with the name <cFieldName> in work area number <nWorkArea>, the code block return NIL.
Example(s)
LOCAL bField
// this block work on the field "name" that exist on work area 2
bFiled := FIELDBLOCK( "name", 2 )
// open a file named One in work area 1
// that have a field named "name"
SELECT 1
USE One
// open a file named Two in work area 2
// it also have a field named "name"
SELECT 2
USE Two
SELECT 1
? "Original names: ", One->name, Two->name
? "Name value for file Two :", EVAL( bField )
EVAL( bField, "Two has new name" )
? "and now: ", One->name, Two->name
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'If the block is evaluate and there is no field with the name <cFieldName> in the given work area, the code block return NIL.
CA-Cl*pper would raise BASE/1003 error if the field does not exist.'
File(s)
Library is rtl
See also
EVAL(),FIELDBLOCK(),MEMVARBLOCK()
Index
API

Strings

ALLTRIM()

Removes leading and trailing blank spaces from a string
Syntax
ALLTRIM( <cString> ) --> cExpression
Argument(s)
<cString> Any character string
Returns
<cExpression> An string will all blank spaces removed from <cString>
Description
This function returns the string <cExpression> will all leading and trailing blank spaces removed.
Example(s)
? ALLTRIM( "HELLO HARBOUR" )
? ALLTRIM( "     HELLO HARBOUR" )
? ALLTRIM( "HELLO HARBOUR     " )
? ALLTRIM( "     HELLO HARBOUR     " )
Test(s)
See Examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
LTRIM(),RTRIM(),TRIM()
Index
API

ASC()

Returns the ASCII value of a character
Syntax
ASC( <cCharacter> ) --> nAscNumber
Argument(s)
<cCharacter> Any character expression
Returns
<nAscNumber> ASCII value
Description
This function return the ASCII value of the leftmost character of any character expression passed as <cCharacter>.
Example(s)
? ASC( "A" )
? ASC( "¹" )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
CHR()
Index
API

AT()

Locates the position of a substring in a main string.
Syntax
AT( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
Argument(s)
<cSearch> Substring to search for
<cString> Main string
<nStart> First position to search in cString, by default 1
<nEnd> End posistion to search, by default cString length
Returns
AT() return the starting position of the first occurrence of the substring in the main string
Description
This function searches the string <cString> for the characters in the first string <cSearch>. If the substring is not contained within the second expression, the function will return 0. The third and fourth parameters lets you indicate a starting and end offset to search in.
Example(s)
QOUT( "at( 'cde', 'abcdefgfedcba' ) = '" +;
at( 'cde', 'abcsefgfedcba' ) + "'" )
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is sensitive to HB_CLP_STRICT settings during the compilation of src/rtl/at.c
<nStart> and <nEnd> are Harbour extensions and do not exist if HB_CLP_STRICT is defined. In that case, the whole string is searched.'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
RAT()
Index
API

CHR()

Converts an ASCII value to it character value
Syntax
CHR( <nAsciiNum> ) --> cReturn
Argument(s)
<nAsciiNum> Any ASCII character code.
Returns
<cReturn> Character expression of that ASCII value
Description
This function returns the ASCII character code for <nAsciiNum>. The number expressed must be an interger value within the range of 0 to 255 inclusive. The CHR() function will send the character returned to whatever device is presently set.
The CHR() function may be used for printing special codes as well as normal and graphics character codes.
Example(s)
? CHR( 32 )
? chr( 215 )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ASC(), INKEY()
Index
API

HARDCR()

Replace all soft carriage returns with hard carriages returns.
Syntax
HARDCR( <cString> ) --> <cConvertedString>
Argument(s)
<cString> is a string of chars to convert.
Returns
<cConvertedString> Trasformed string.
Description
Returns a string/memo with soft carriage return chars converted to hard carriage return chars.
Example(s)
? HARDCR( Data->CNOTES )
Test(s)
@ 1, 1 SAY HARDCR( Data->CNOTES )
will display converted string starting on row two, column two of the
current device.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
MEMOTRAN(),STRTRAN()
Index
API

HB_ANSITOOEM()

Convert a windows Character to a Dos based character
Syntax
HB_ANSITOOEM( <cString> ) --> cDosString
Argument(s)
<cString> Windows ansi string to convert to DOS oem String
Returns
<cDosString> Dos based string
Description
This function converts each character in <cString> to the corresponding character in the MS-DOS (OEM) character set. The character expression <cString> should contain characters from the ANSI character set. If a character in <cString> doesn't have a MS-DOS equivalent, the character is converted to a similar MS-DOS character.
Example(s)
? HB_OEMTOANSI( "Harbour" )
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on the MS-Windows platform(s)
File(s)
Library is rtl
See also
HB_OEMTOANSI()
Index
API

HB_OEMTOANSI()

Convert a DOS(OEM) Character to a WINDOWS (ANSI) based character
Syntax
HB_OEMTOANSI( <cString> ) --> cDosString
Argument(s)
<cString> DOS (OEM) string to convert to WINDOWS (ANSI) String
Returns
<cDosString> WINDOWS based string
Description
This function converts each character in <cString> to the corresponding character in the Windows (ANSI) character set. The character expression <cString> should contain characters from the OEM character set. If a character in <cString> doesn't have a ANSI equivalent, the character is remais the same.
Example(s)
? HB_OEMTOANSI( "Harbour" )
Status
Ready
Compliance
This is Harbour specific
Platform(s)
This is available on the MS-Windows platform(s)
File(s)
Library is rtl
See also
HB_ANSITOOEM()
Index
API

HB_VALTOSTR()

Converts any scalar type to a string.
Syntax
HB_VALTOSTR( <xValue> ) --> cString
Argument(s)
<xValue> is any scalar argument.
Returns
<cString> A string representation of <xValue> using default conversions.
Description
HB_VALTOSTR can be used to convert any scalar value to a string.
Example(s)
? HB_VALTOSTR( 4 )
? HB_VALTOSTR( "String" )
Test(s)
? HB_VALTOSTR( 4 ) == "         4"
? HB_VALTOSTR( 4.0 / 2 ) == "         2.00"
? HB_VALTOSTR( "String" ) == "String"
? HB_VALTOSTR( CTOD( "01/01/2001" ) ) == "01/01/01"
? HB_VALTOSTR( NIL ) == "NIL"
? HB_VALTOSTR( .F. ) == ".F."
? HB_VALTOSTR( .T. ) == ".T."
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
STR()
Index
API

ISALPHA()

Checks if leftmost character in a string is an alphabetic character
Syntax
ISALPHA( <cString> ) --> lAlpha
Argument(s)
<cString> Any character string
Returns
lAlpha Logical true (.T.) or false (.F.).
Description
This function return a logical true (.T.) if the first character in <cString> is an alphabetic character. If not, the function will return a logical false (.F.).
Example(s)
QOUT( "isalpha( 'hello' ) = ", isalpha( 'hello' ) )
QOUT( "isalpha( '12345' ) = ", isalpha( '12345' ) )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ISDIGIT(),ISLOWER(),ISUPPER(),LOWER(),UPPER()
Index
API

ISDIGIT()

Checks if leftmost character is a digit character
Syntax
ISDIGIT( <cString> ) --> lDigit
Argument(s)
<cString> Any character string
Returns
lDigit Logical true (.T.) or false (.F.).
Description
This function takes the caracter string <cString> and checks to see if the leftmost character is a digit, from 1 to 9. If so, the function will return a logical true (.T.); otherwise, it will return a logical false (.F.).
Example(s)
? ISDIGIT( '12345' )      // .T.
? ISDIGIT( 'abcde' )      // .F.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ISALPHA(),ISLOWER(),ISUPPER(),LOWER(),UPPER()
Index
API

ISLOWER()

Checks if leftmost character is an lowercased letter.
Syntax
ISLOWER( <cString> ) --> lLower
Argument(s)
<cString> Any character string
Returns
lLower Logical true (.T.) or false (.F.).
Description
This function takes the caracter string <cString> and checks to see if the leftmost character is a lowercased letter. If so, the function will return a logical true (.T.); otherwise, it will return a logical false (.F.).
Example(s)
? islower( 'ABCde' )      // .F.
? islower( 'aBCde' )      // .T.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ISALPHA(),ISDIGIT(),ISUPPER(),LOWER(),UPPER()
Index
API

ISUPPER()

Checks if leftmost character is an uppercased letter.
Syntax
ISUPPER( <cString> ) --> lUpper
Argument(s)
<cString> Any character string
Returns
lUpper Logical true (.T.) or false (.F.).
Description
This function checks to see if the leftmost character if <cString> is a uppercased letter. If so, the function will return a logical true (.T.); otherwise, it will return a logical false (.F.).
Example(s)
? ISUPPER( 'Abcde' )    // .T.
? ISUPPER( 'abcde' )    // .F.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ISALPHA(),ISLOWER(),ISDIGIT(),LOWER(),UPPER()
Index
API

LEFT()

Extract the leftmost substring of a character expression
Syntax
LEFT( <cString>, <nLen> ) --> cReturn
Argument(s)
<cString> Main character to be parsed
<nLen> Number of bytes to return beggining at the leftmost position
Returns
<cReturn> Substring of evaluation
Description
This functions returns the leftmost <nLen> characters of <cString>. It is equivalent to the following expression:
SUBSTR( <cString>, 1, <nLen> )
Example(s)
? LEFT( 'HELLO HARBOUR', 5 )    // HELLO
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SUBSTR(),RIGHT(),AT(),RAT()
Index
API

LOWER()

Universally lowercases a character string expression.
Syntax
LOWER( <cString> ) --> cLowerString
Argument(s)
<cString> Any character expression.
Returns
<cLowerString> Lowercased value of <cString>
Description
This function converts any character expression passes as <cString> to its lowercased representation.Any nonalphabetic character withing <cString> will remain unchanged.
Example(s)
? LOWER( "HARBOUR" )      // harbour
? LOWER( "Hello All" )    // hello all
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
UPPER(),ISLOWER(),ISUPPER()
Index
API

LTRIM()

Removes leading spaces from a string
Syntax
LTRIM( <cString> ) --> cReturn
Argument(s)
<cString> Character expression with leading spaces
Returns
LTRIM() returns a copy of the original string with leading spaces removed.
Description
This function trims the leading space blank
Example(s)
? LTRIM( "HELLO     " )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
TRIM(),RTRIM(),ALLTRIM()
Index
API

MEMOREAD()

Return the text file's contents as a character string
Syntax
MEMOREAD( <cFileName> ) --> cString
Argument(s)
<cFileName> is the filename to read from disk.
It must include the file extension. If file to be read lives in another directory, you must include the path.
Returns
Returns the contents of a text file as a character string.
If <cFileName> cannot be found or read MEMOREAD returns an empty string ("").
Description
MEMOREAD() is a function that reads the content of a text file (till now) from disk (floppy, HD, CD-ROM, etc.) into a memory string. In that way you can manipulate as any character string or assigned to a memo field to be saved in a database.
MEMOREAD() function is used together with MEMOEDIT() and MEMOWRIT() to get from disk text from several sources that would be edited, searched, replaced, displayed, etc.
It is used to import data from other sources to our database.
Note: MEMOREAD() does not use the settings SET DEFAULT or SET PATH to search for <cFileName>. It searches for <cFileName> in the current directory. If the file is not found, then MEMOREAD() searches in the DOS path.
Over a network, MEMOREAD() attempts to open <cFileName> in read-only mode and shared. If the file is used in mode exclusive by another process, the function will returns a null string ("").
Example(s)
*  This example uses MEMOREAD() to assign the contents of a text
file to a character variable for later search
cFile   := "account.prg"
cString := MEMOREAD( cFile )
IF AT( "Melina", cString) == 0             // check for copyright
MEMOWRIT( cFile, cCopyright + cString ) // if not, add it!
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
MEMOEDIT(),MEMOWRIT(),REPLACE
Index
API

MEMOTRAN()

Converts hard and soft carriage returns within strings.
Syntax
MEMOTRAN( <cString>, <cHard>, <cSoft> ) --> <cConvertedString>
Argument(s)
<cString> is a string of chars to convert.
<cHard> is the character to replace hard returns with. If not specified defaults to semicolon.
<cSoft> is the character to replace soft returns with. If not specified defaults to single space.
Returns
<cConvertedString> Trasformed string.
Description
Returns a string/memo with carriage return chars converted to specified chars.
Example(s)
? MEMOTRAN( DATA->CNOTES )
Test(s)
@ 1, 1 SAY MEMOTRAN( Data->CNOTES )
will display converted string starting on row two, column two of the
current device.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
HARDCR(),STRTRAN()
Index
API

MEMOWRIT()

Write a memo field or character string to a text file on disk
Syntax
MEMOWRIT( <cFileName>, <cString>, [<lWriteEof>] ) --> lSuccess
Argument(s)
<cFileName> is the filename to read from disk.
It must include the file extension. If file to be read lives in another directory, you must include the path.
<cString> Is the memo field or character string, to be write to
<cFile>.
<lWriteEof> Is a logic variable that settle if the "end of file"
character - CHR(26) - is written to disk. This parameter is optional. By default is true (.T.)
Returns
Function returns true (.T.) if the writing operation was successful; otherwise, it returns false (.F.).
Description
This a function that writes a memo field or character string to a text file on disk (floppy, HD, CD-ROM, etc.) If you not specified a path, MEMOWRIT() writes <cFileName> to the current directory. If <cFileName> exists, it is overwritten.
There is a third parameter (optional), <lWriteEof>, (not found in CA-Cl*pper) which let to programmer change the default behavior of - allways - to write the EOF character, CHR(26) as in CA-Cl*pper.
If there is no third parameter, nothing change, EOF is written as in CA-Cl*pper, the same occurs when <lWriteEof> is set to .T. But, if <lWriteEof> is set to .F., EOF char is Not written to the end of the file.
MEMOWRIT() function is used together with MEMOREAD() and MEMOEDIT() to save to disk text from several sources that was edited, searched, replaced, displayed, etc.
Note that MEMOWRIT() do not use the directory settings SET DEFAULT.
Example(s)
*  This example uses MEMOWRIT() to write the contents of a character
variable to a text file.
cFile   := "account.prg"
cString := MEMOREAD( cFile )
IF AT( "Melina", cString) == 0             // check for copyright
MEMOWRIT( cFile, cCopyright + cString ) // if not, add it!
ENDIF
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
MEMOEDIT(),MEMOREAD()
Index
API

PADC()

Centers an expression for a given width
Syntax
PADC( <xVal>, <nWidth>, <cFill> ) --> cString
Argument(s)
<xVal> A Number, Character or Date value to pad
<nWidth> Width of output string
<cFill> Character to fill in the string
Returns
<cString> The Center string of <xVal>
Description
This function takes an date, number or character expression <xVal> and attempt to center the expression within a string of a given width expressed as <nWidth>. The default character used to pad either side of <xVal> will be a blank space. This character may be explicitly specified the value of <cFill>.
If the length of <xVal> is longer then <nWidth>, this function will truncate the string <xVal> from the leftmost side to the length of <nWidth>.
Example(s)
? PADC( 'Harbour',20 )
? PADC( 34.5142, 20 )
? PADC( Date(), 35 )
Test(s)
See Examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ALLTRIM(),PADL(),PADR()
Index
API

PADL()

Left-justifies an expression for a given width
Syntax
PADL( <xVal>, <nWidth>, <cFill> ) --> cString
Argument(s)
<xVal> An number,Character or date to pad
<nWidth> Width of output string
<cFill> Character to fill in the string
Returns
<cString> The left-justifies string of <xVal>
Description
This function takes an date,number,or character expression <xVal> and attempt to left-justify it within a string of a given width expressed as <nWidth>. The default character used to pad left side of <xVal> will be an blank space; however, this character may be explicitly specified the value of <cFill>.
If the length of <xVal> is longer then <nWidth>, this function will truncate the string <xVal> from the leftmost side to the length of <nWidth>.
Example(s)
? PADL( 'Harbour', 20 )
? PADL( 34.5142, 20 )
? PADL( Date(), 35 )
Test(s)
See examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ALLTRIM(),PADC(),PADR()
Index
API

PADR()

Right-justifies an expression for a given width
Syntax
PADR( <xVal>, <nWidth>, <cFill> ) --> cString
Argument(s)
<xVal> A Number, Character or Date value to pad
<nWidth> Width of output string
<cFill> Character to fill in the string
Returns
<cString> The right-justifies string of <xVal>
Description
This function takes an date,number,or character expression <xVal> and attempt to right-justify it within a string of a given width expressed as <nWidth>. The default character used to pad right side of <xVal> will be an blank space; however, this character may be explicitly specified the value of <cFill>.
If the length of <xVal> is longer then <nWidth>, this function will truncate the string <xVal> from the leftmost side to the length of <nWidth>.
Example(s)
? PADR( 'Harbour', 20 )
? PADR( 34.5142, 20 )
? PADR( Date(), 35 )
Test(s)
See examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ALLTRIM(),PADC(),PADL()
Index
API

RAT()

Searches for a substring from the right side of a string.
Syntax
RAT( <cSearch>, <cString> ) --> nPos
Argument(s)
<cSearch> Substring to search for
<cString> Main string
Returns
RAT() return the location of beginnig position.
Description
This function searches througt <cString> for the first existence of <cSearch>. The search operation is performed from the right side of <cString> to the left. If the function is unable to find any occurence of <cSearch> in <cString>, the return value is 0.
Example(s)
QOUT( "rat( 'cde', 'abcdefgfedcba' ) = '" +;
rat( 'cde', 'abcsefgfedcba' ) + "'" )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
AT(), SUBSTR(), RIGHT()
Index
API

REPLICATE()

Repeats a single character expression
Syntax
REPLICATE( <cString>, <nSize> ) --> cReplicateString
Argument(s)
<cString> Character string to be replicated
<nSize> Number of times to replicate <cString>
Returns
<cReplicateString> A character expression containg the <cString> fill character.
Description
This function returns a string composed of <nSize> repetitions of <cString>. The length of the character string returned by this function is limited to the memory avaliable.
A value of 0 for <nSize> will return a NULL string.
Example(s)
? REPLICATE( 'a', 10 )      // aaaaaaaaaa
? REPLICATE( 'b', 100000 )
Test(s)
See Examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
SPACE(),PADC(),PADL(),PADR()
Index
API

RIGHT()

Extract the rightmost substring of a character expression
Syntax
RIGHT( <cString>, <nLen> ) --> cReturn
Argument(s)
<cString> Character expression to be parsed
<nLen> Number of bytes to return beggining at the rightmost position
Returns
<cReturn> Substring of evaluation
Description
This functions returns the rightmost <nLen> characters of <cString>. It is equivalent to the following expressions:
SUBSTR( <cString>, - <nLen> )
SUBSTR( <cString>, LEN( <cString> ) - <nLen> + 1, <nLen> )
Example(s)
? RIGHT( 'HELLO HARBOUR', 5 )     // RBOUR
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
SUBSTR(),LEFT(),AT(),RAT()
Index
API

RTRIM()

Remove trailing spaces from a string.
Syntax
RTRIM( <cExpression> ) --> cString
Argument(s)
<cExpression> Any character expression
Returns
<cString> A formated string with out any blank spaced.
Description
This function returns the value of <cString> with any trailing blank removed.
This function is indentical to RTRIM() and the opposite of LTRIM(). Together with LTRIM(), this function equated to the ALLTRIM() function.
Example(s)
? RTRIM( "HELLO" )              //  "HELLO"
? RTRIM( "" )                   //  ""
? RTRIM( "UA   " )              //  "UA"
? RTRIM( "   UA" )              //  "   UA"
Test(s)
See Examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ALLTRIM(),LTRIM(),TRIM()
Index
API

SPACE()

Returns a string of blank spaces
Syntax
SPACE( <nSize> ) --> cString
Argument(s)
<nSize> The length of the string
Returns
<cString> A string containing blank spaces
Description
This function returns a string consisting of <nSize> blank spaces. If the value of <nSize> is 0, a NULL string ( "" ) will be returned.
This function is useful to declare the length of a character memory variable.
Example(s)
FUNC MAIN
LOCAL cBigString
LOCAL cFirst
LOCAL cString := Space(20)   // Create an character memory variable
// with length 20
? len(cString)      // 20
cBigString:=space(100000)    // create a memory variable with 100000
// blank spaces
?  len(cBigString)
Use Tests New
cFirst:= makeempty(1)
? len(cFirst)
Return Nil
Function MakeEmpty(xField)
LOCAL nRecord
LOCAL xRetValue
If !empty(alias())
nRecord:=recno()
dbgoto(0)
if valtype(xField)=="C"
xField:= ascan(dbstruct(),{|aFields| aFields[1]==upper(xfield)})
else
default xField to 0
if xField < 1 .or. xField>fcount()
xfield:=0
endif
endif
if !(xfield ==0)
xRetvalue:=fieldget(xfield)
endif
dbgoto(nrecord)
endif
return xRetvalue
Test(s)
See examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
PADC(),PADL(),PADR(),REPLICATE()
Index
API

STR()

Convert a numeric expression to a character string.
Syntax
STR( <nNumber>, [<nLength>], [<nDecimals>] ) --> cNumber
Argument(s)
<nNumber> is the numeric expression to be converted to a character string.
<nLength> is the length of the character string to return, including decimal digits, decimal point, and sign.
<nDecimals> is the number of decimal places to return.
Returns
STR() returns <nNumber> formatted as a character string. If the optional length and decimal arguments are not specified, STR() returns the character string according to the following rules:
Results of STR() with No Optional Arguments

Expression Return Value Length
Field Variable Field length plus decimals
Expressions/constants Minimum of 10 digits plus decimals
VAL() Minimum of 3 digits
MONTH()/DAY() 3 digits
YEAR() 5 digits
RECNO() 7 digits

Description
STR() is a numeric conversion function that converts numeric values to character strings. It is commonly used to concatenate numeric values to character strings. STR() has applications displaying numbers, creating codes such as part numbers from numeric values, and creating index keys that combine numeric and character data.
STR() is like TRANSFORM(), which formats numeric values as character strings using a mask instead of length and decimal specifications.
The inverse of STR() is VAL(), which converts character numbers to numerics.
* If <nLength> is less than the number of whole number digits in
<nNumber>, STR() returns asterisks instead of the number.
* If <nLength> is less than the number of decimal digits
required for the decimal portion of the returned string, Harbour rounds the number to the available number of decimal places.
* If <nLength> is specified but <nDecimals> is omitted (no
decimal places), the return value is rounded to an integer.
Example(s)
? STR( 10, 6, 2 ) // " 10.00"
? STR( -10, 8, 2 ) // "  -10.00"
Test(s)
See the regression test suit for comprehensive tests.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
STRZERO(),TRANSFORM(),VAL()
Index
API

STRTRAN()

Translate substring value with a main string
Syntax
STRTRAN( <cString>, <cLocString>, [<cRepString>], [<nPos>],
[<nOccurences>] ) --> cReturn
Argument(s)
<cString> The main string to search
<cLocString> The string to locate in the main string
<cRepString> The string to replace the <cLocString>
<nPos> The first occurence to be replaced
<nOccurences> Number of occurence to replace
Returns
<cReturn> Formated string
Description
This function searches for any occurence of <cLocString> in <cString> and replacesit with <cRepString>. If <cRepString> is not specified, a NULL byte will replace <cLocString>.
If <nPos> is used, its value defines the first occurence to be replaced. The default value is 1. Additionally, if used, the value of <nOccurences> tell the function how many occurrences of <cLocString> in <cString> are to the replaced. The default of <nOccurences> is all occurrences.
Example(s)
? STRTRAN( "Harbour  Power", "  ", " " )   // Harbour Power
// Harbour Power The future  of  xBase
? STRTRAN( "Harbour  Power  The Future  of  xBase", "  ", " " ,, 2 )
Test(s)
See regression test
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Libraty is rtl
See also
SUBSTR(),AT()
Index
API

STRZERO()

Convert a numeric expression to a character string, zero padded.
Syntax
STRZERO( <nNumber>, [<nLength>], [<nDecimals>] ) --> cNumber
Argument(s)
<nNumber> is the numeric expression to be converted to a character string.
<nLength> is the length of the character string to return, including decimal digits, decimal point, and sign.
<nDecimals> is the number of decimal places to return.
Returns
STRZERO() returns <nNumber> formatted as a character string. If the optional length and decimal arguments are not specified, STRZERO() returns the character string according to the following rules:
Results of STRZERO() with No Optional Arguments

Expression Return Value Length
Field Variable Field length plus decimals
Expressions/constants Minimum of 10 digits plus decimals
VAL() Minimum of 3 digits
MONTH()/DAY() 3 digits
YEAR() 5 digits
RECNO() 7 digits

Description
STRZERO() is a numeric conversion function that converts numeric values to character strings. It is commonly used to concatenate numeric values to character strings. STRZERO() has applications displaying numbers, creating codes such as part numbers from numeric values, and creating index keys that combine numeric and character data.
STRZERO() is like TRANSFORM(), which formats numeric values as character strings using a mask instead of length and decimal specifications.
The inverse of STRZERO() is VAL(), which converts character numbers to numerics.
* If <nLength> is less than the number of whole number digits in
<nNumber>, STR() returns asterisks instead of the number.
* If <nLength> is less than the number of decimal digits
required for the decimal portion of the returned string, Harbour rounds the number to the available number of decimal places.
* If <nLength> is specified but <nDecimals> is omitted (no
decimal places), the return value is rounded to an integer.
The STRZERO() function was part of the CA-Cl*pper samples.
Example(s)
? STRZERO( 10, 6, 2 ) // "010.00"
? STRZERO( -10, 8, 2 ) // "-0010.00"
Test(s)
see the regression test suit for comprehensive tests.
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
STR()
Index
API

SUBSTR()

Returns a substring from a main string
Syntax
SUBSTR( <cString>, <nStart>, [<nLen>] ) --> cReturn
Argument(s)
<cString> Character expression to be parsed
<nStart> Start position
<nLen> Number of characters to return
Returns
<cReturn> Substring of evaluation
Description
This functions returns a character string formed from <cString>, starting at the position of <nStart> and continuing on for a length of <nLen> characters. If <nLen> is not specified, the value will be all remaining characters from the position of <nStart>.
The value of <nStart> may be negative. If it is, the direction of operation is reversed from a default of left-to-right to right-to-left for the number of characters specified in <nStart>. If the number of characters from <nStart> to the end of the string is less than <nLen> the rest are ignored.
Example(s)
? SUBSTR( 'HELLO HARBOUR' , 7, 4 )      // HARB
? SUBSTR( 'HELLO HARBOUR' ,-3, 3 )      // OUR
? SUBSTR( 'HELLO HARBOUR' , 7    )      // HARBOUR
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms though some platforms have a string length limit of 64KB
File(s)
Library is rtl
See also
LEFT(),AT(),RIGHT()
Index
API

TRANSFORM()

Formats a value based on a specific picture template.
Syntax
TRANSFORM( <xExpression>, <cTemplate> ) --> cFormated
Argument(s)
<xExpression> Any expression to be formated.
<cTemplate> Character string with picture template
Returns
<cFormated> Formatted expression in character format
Description
This function returns <xExpression> in the format of the picture expression passed to the function as <cTemplate>.
Their are two components that can make up <cTemplate> : a function string and a template string.Function strings are those functions that globally tell what the format of <xExpression> should be. These functions are represented by a single character precede by the @ symbol.
There are a couple of rules to follow when using function strings and template strings:
- First, a single space must fall between the function template
and the template string if they are used in conjunction with one another.
- Second, if both components make up the value of <cTemplate>, the
function string must precede the template string. Otherwise, the function string may appear with out the template string and vice versa.
The table below shows the possible function strings avaliable with the TRANSFORM() function.

@B Left justify the string within the format.
@C Issue a CR after format is numbers are positive.
@D Put dates in SET DATE format.
@E Put dates in BRITISH format.
@L Make a zero padded string out of the number.
@R Insert nontemplate characters.
@X Issue a DB after format is numbers are negative.
@Z Display any zero as blank spaces.
@( Quotes around negative numbers
@! Convert alpha characters to uppercased format.

The second part of <cTemplate> consists of the format string.Each character in the string may be formated based on using the follow characters as template markers for the string.

A,N,X,9,# Any data type
L Shows logical as "T" or "F"
Y Shows logical as "Y" or "N"
! Convert to uppercase
$ Dolar sing in place of leading spaces in numeric expression
* Asterisks in place of leading spaces in numeric expression
, Commas position
. Decimal point position

Example(s)
LOCAL cString := 'This is harbour'
LOCAL nNumber := 9923.34
LOCAL nNumber1 := -95842.00
LOCAL lValue := .T.
LOCAL dDate := DATE()
? 'working with String'
? "Current String is", cString
? "All uppercased", TRANSFORM( cString, "@!" )
? "Date is", ddate
? "Date is ", TRANSFORM( ddate, "@D" )
? TRANSFORM( nNumber, "@L 99999999" )  //  "009923.34"
? TRANSFORM( 0      , "@L 9999"     )  //  "0000"
Test(s)
See regression Test
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'The @L function template is a FoxPro/Xbase++ Extension'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
@...SAY,DEVOUTPICT()
Index
API

TRIM()

Remove trailing spaces from a string.
Syntax
TRIM( <cExpression> ) --> cString
Argument(s)
<cExpression> Any character expression
Returns
<cString> A formated string with out any blank spaced.
Description
This function returns the value of <cString> with any trailing blank removed.
This function is indentical to RTRIM() and the opposite of LTRIM(). Together with LTRIM(), this function equated to the ALLTRIM() function.
Example(s)
? TRIM( "HELLO" )     //  "HELLO"
? TRIM( "" )          //   ""
? TRIM( "UA   " )     //   "UA"
? TRIM( "   UA" )     //   "   UA"
Test(s)
See Examples
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
RTRIM(),LTRIM(),ALLTRIM()
Index
API

UPPER()

Converts a character expression to uppercase format
Syntax
UPPER( <cString> ) --> cUpperString
Argument(s)
<cString> Any character expression.
Returns
<cUpperString> Uppercased value of <cString>
Description
This function converts all alpha characters in <cString> to upper case values and returns that formatted character expression.
Example(s)
? UPPER( "harbour" )       // HARBOUR
? UPPER( "Harbour" )       // HARBOUR
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
LOWER(),ISUPPER(),ISLOWER()
Index
API

VAL()

Convert a number from a character type to numeric
Syntax
VAL( <cNumber> ) --> nNumber
Argument(s)
<cNumber> Any valid character string of numbers.
Returns
<nNumber> The numeric value of <cNumber>
Description
This function converts any number previosly defined as an character expression <cNumber> into a numeric expression.
This functions is the oppose of the STR() function.
Example(s)
? VAL( '31421' ) // 31421
Test(s)
See regression test
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
STR(),TRANSFORM()
Index
API

Terminal

COL()

Returns the current screen column position
Syntax
COL() --> nPosition
Argument(s)
None.
Returns
<nPosition> Current column position
Description
This function returns the current cursor column position. The value for this function can range between 0 and MAXCOL().
Example(s)
? Col()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
ROW(),MAXROW(),MAXCOL()
Index
API

DEVOUTPICT()

Displays a value to a device using a picture template
Syntax
DEVOUTPICT( <xExp>, <cPicture>, [<cColorString>] )
Argument(s)
<xExp> is any valid expression.
<cPicture> is any picture transformation that TRANSFORM() can use.
<cColorString> is an optional string that specifies a screen color to use in place of the default color when the output goes to the screen.
Description
Outputs any expression using a picture transformation instead of using the default transformation for the type of expression.
Example(s)
// Output a negative dollar amount using debit notation.
DEVOUTPICT( -1.25, "@D$ 99,999.99 )
Test(s)
@ 3,1 SAY -1.25 PICTURE "@D$ 99,999.99"
will display "$(     1.25)" starting on row four, column two of the
current device (without the double quotation marks, of course).
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'DEVOUTPICT() is mostly CA-Cl*pper compliant. Any differences are due to enhancements in the Harbour TRANSFORM() over CA-Cl*pper.'
File(s)
Library is rtl
See also
DEVOUT(),TRANSFORM()
Index
API

MAXCOL()

Returns the maximun number of columns in the current video mode
Syntax
MAXCOL() --> nPosition
Argument(s)
None.
Returns
<nPosition> The maximun number of columns possible in current video mode
Description
This function returns the current cursor column position. The value for this function can range between 0 and MAXCOL().
Example(s)
? MAXCol()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
Unknown 'PLATFORMS' code: 'Linux(GT),OS2(GT),Win(GT)'
File(s)
Library is rtl
See also
ROW(),MAXROW(),COL()
Index
API

MAXROW()

Returns the current screen row position
Syntax
MAXROW() --> nPosition
Argument(s)
None.
Returns
<nPosition> The maximun number of rows possible in current video mode
Description
This function returns the current cursor row location. The value for this function can range between 0 and MAXCOL().
Example(s)
? MAXROW()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
Unknown 'PLATFORMS' code: 'Linux(GT),OS2(GT),Win(GT)'
File(s)
Library is rtl
See also
COL(),ROW(),MAXCOL()
Index
API

RESTORE SCREEN

Restore screen image and coordinate from an internal buffer
Syntax
RESTORE SCREEN
Argument(s)
none.
Description
Rest Screen restore saved image of the whole screen from an internal buffer that was saved by Save Screen, it also restore cursor position. After a call to Rest Screen the internal buffer is cleared.
RESTORE SCREEN command is preprocessed into __XRestScreen() function during compile time. Note that RESTORE SCREEN FROM is preprocessed into RESTSCREEN() function.
Example(s)
// save the screen, display list of files than restore the screen
SAVE SCREEN
DIR *.*
WAIT
RESTORE SCREEN
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This part of the GT API and supported only by some platforms.
See also
__XRESTSCREEN(),SAVE SCREEN,__XSAVESCREEN()
Index
API

ROW()

Returns the current screen row position
Syntax
ROW() --> nPosition
Argument(s)
None.
Returns
<nPosition> Current screen row position
Description
This function returns the current cursor row location. The value for this function can range between 0 and MAXCOL().
Example(s)
? Row()
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
COL(),MAXROW(),MAXCOL()
Index
API

SAVE SCREEN

Save whole screen image and coordinate to an internal buffer
Syntax
SAVE SCREEN
Argument(s)
none.
Description
SAVE SCREEN save the image of the whole screen into an internal buffer, it also save current cursor position. The information could later be restored by REST SCREEN. Each call to SAVE SCREEN overwrite the internal buffer.
SAVE SCREEN command is preprocessed into __XSaveScreen() function during compile time. Note that SAVE SCREEN TO is preprocessed into SAVESCREEN() function.
Example(s)
// save the screen, display list of files than restore the screen
SAVE SCREEN
DIR *.*
WAIT
RESTORE SCREEN
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This part of the GT API and supported only by some platforms.
See also
RESTORE SCREEN,__XRESTSCREEN(),__XSAVESCREEN()
Index
API

__TYPEFILE()

Show the content of a file on the console and/or printer
Syntax
__TYPEFILE( <cFile>, [<lPrint>] ) --> NIL
Argument(s)
<cFile> is a name of the file to display. If the file have an extension, it must be specified (there is no default value).
<lPrint> is an optional logical value that specifies whether the output should go only to the screen (.F.) or to both the screen and printer (.T.), the default is (.F.).
Returns
__TYPEFILE() always return NIL.
Description
__TYPEFILE() function type the content of a text file on the screen with an option to send this information also to the printer. The file is displayed as is without any headings or formating.
If <cFile> contain no path, __TYPEFILE() try to find the file first in the SET DEFAULT directory and then in search all of the SET PATH directories. If <cFile> can not be found a run-time error occur.
Use SET CONSOLE OFF to suppress screen output. You can pause the output using Ctrl-S, press any key to resume.
__TYPEFILE() function is used in the preprocessing of the TYPE command.
Example(s)
The following examples assume a file name mytext.dat exist in all
specified paths, a run-time error would displayed if it does not
// display mytext.dat file on screen
__TYPEFILE( "mytext.dat" )
// display mytext.dat file on screen and printer
__TYPEFILE( "mytext.dat", .T. )
// display mytext.dat file on printer only
SET CONSOLE OFF
__TYPEFILE( "mytext.dat", .T. )
SET CONSOLE ON
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
COPY FILE,SET DEFAULT,SET PATH,SET PRINTER,TYPE
Index
API

hb_ColorIndex()

Extract one color from a full colorspec string.
Syntax
hb_ColorIndex( <cColorSpec>, <nIndex> ) --> <cColor>
Argument(s)
<cColorSpec> is a color list
<nIndex> is the position of the color item to be extracted, the first position is the zero.
Returns
The selected color string, or if anything goes wrong, an empty string.
Description
CA-Cl*pper has a color spec string, which has more than one color in it, separated with commas.
This function will extract a given item from this list. You may use the manifest constants defined in color.ch to identify and extract common colors.
Example(s)
? hb_ColorIndex( "W/N, N/W", CLR_ENHANCED ) // "N/W"
Test(s)
see the regression test suit for comprehensive tests.
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
ColorSelect()
Index
API

User interface

ACHOICE()

Allows selection of an element from an array
Syntax
ACHOICE(<nTop>, <nLeft>, <nBottom>, <nRight>, <acMenuItems>, [<alSelableItems> | <lSelableItems>], [<cUserFunction> | <bUserBlock>], [<nInitialItem>], [<nWindowRow>]) --> nPosition
Argument(s)
<nTop> - topmost row used to display array (default 0)
<nLeft> - leftmost row used to display array (default 0)
<nBottom> - bottommost row used to display array (default MAXROW())
<nRight> - rightmost row used to display array (default MAXCOL())
<acMenuItems> - the character array of items from which to select
<alSelableItems> - an array of items, either logical or character,
which is used to determine if a particular item may be selected. If the type of a given item is character, it is macro evaluated, and the result is expected to be a logical. A value of .T. means that the item may be selected, .F. that it may not. (See next argument: lSelectableItems)
<lSelableItems> - a logical value which is used to apply to all
items in acMenuItems. If .T., all items may be selected; if .F., none may be selected. (See previous argument: alSelectableItems) Default .T.
<cUserFunction> - the name of a function to be called which may
affect special processing of keystrokes. It is specified without parentheses or parameters. When it is called, it will be supplied with the parameters: nMode, nCurElement, and nRowPos. Default NIL.
<bUserBlock> - a codeblock to be called which may
affect special processing of keystrokes. It should be specified in the form {|nMode, nCurElemenet, nRowPos| ; MyFunc(nMode, nCurElemenet, nRowPos) }. Default NIL.
<nInitialItem> - the number of the element to be highlighted as
the current item when the array is initially displayed. 1 origin. Default 1.
<nWindowRow> - the number of the window row on which the initial
item is to be displayed. 0 origin. Default 0.
Returns
<nPosition> - the number of the item to be selected, or 0 if the selection was aborted.
Description
Allows selection of an element from an array. Please see standard CA-Cl*pper documentation for ACHOICE for additional detail.
Example(s)
aItems := { "One", "Two", "Three" }
nChoice := ACHOICE( 10, 10, 20, 20, aItems )
IF nChoice == 0
? "You did not choose an item"
ELSE
? "You chose element " + LTRIM( STR( nChoice ) )
?? " which has a value of " + aItems[ nChoice ]
ENDIF
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
MENU TO
Index
API

ALERT()

Display a dialog box with a message
Syntax
ALERT( <xMessage>, [<aOptions>], [<cColorNorm>], [<nDelay>] ) --> nChoice or NIL
Argument(s)
<xMessage> Message to display in the dialog box. <xMessage> can be of any Harbour type. If <xMessage> is an array of Character strings, each element would be displayed in a new line. If <xMessage> is a Character string, you could split the message to several lines by placing a semicolon (;) in the desired places.
<aOptions> Array with available response. Each element should be Character string. If omitted, default is { "Ok" }.
<cColorNorm> Color string to paint the dialog box with. If omitted, default color is "W+/R".
<nDelay> Number of seconds to wait to user response before abort. Default value is 0, that wait forever.
Returns
ALERT() return Numeric value representing option number chosen.
If ESC was pressed, return value is zero.
The return value is NIL if ALERT() is called with no parameters, or if <xMessage> type is not Character and HB_CLP_STRICT option was used. If <nDelay> seconds had passed without user response, the return value is 1.
Description
ALERT() display simple dialog box on screen and let the user select one option. The user can move the highlight bar using arrow keys or TAB key. To select an option the user can press ENTER, SPACE or the first letter of the option.
If the program is executed with the //NOALERT command line switch, nothing is displayed and it simply returns NIL. This switch could be overridden with __NONOALERT().
If the GT system is linked in, ALERT() display the message using the full screen I/O system, if not, the information is printed to the standard output using OUTSTD().
Example(s)
LOCAL cMessage, aOptions, nChoice
// harmless message
cMessage := "Major Database Corruption Detected!;" +  ;
"(deadline in few hours);;"             +  ;
"where DO you want to go today?"
// define response option
aOptions := { "Ok", "www.jobs.com", "Oops" }
// show message and let end user select panic level
nChoice := ALERT( cMessage, aOptions )
DO CASE
CASE nChoice == 0
// do nothing, blame it on some one else
CASE nChoice == 1
? "Please call home and tell them you're gonn'a be late"
CASE nChoice == 2
// make sure your resume is up to date
CASE nChoice == 3
? "Oops mode is not working in this version"
ENDCASE
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'This function is sensitive to HB_CLP_STRICT settings during the compilation of src/rtl/alert.prg
<b>defined</b>: <xMessage> accept Character values only and return NIL if other types are passed.
<b>undefined</b>: <xMessage> could be any type, and internally converted to Character string. If type is Array, multi-line message is displayed.
<b>defined</b>: Only the first four valid <aOptions> are taken.
<b>undefined</b>: <aOptions> could contain as many as needed options.
If HB_COMPAT_C53 was define during compilation of src/rtl/alert.prg the Left-Mouse button could be used to select an option.
The interpretation of the //NOALERT command line switch is done only if HB_CLP_UNDOC was define during compilation of src/rtl/alert.prg
<cColorNorm> is a Harbour extension, or at least un-documented in Clipper 5.2 NG.
<nDelay> is a Harbour extension.'
File(s)
Library is rtl
See also
@...PROMPT,MENU TO,OUTSTD(),__NONOALERT()
Index
API

BROWSE()

Browse a database file
Syntax
BROWSE( [<nTop>, <nLeft>, <nBottom>, <nRight>] ) --> lOk
Argument(s)
<nTop> coordinate for top row display.
<nLeft> coordinate for left column display.
<nBottom> coordinate for bottom row display.
<nRight> coordinate for right column display.
Returns
BROWSE() return .F. if there is no database open in this work area, else it return .T.
Description
BROWSE() is a general purpose database browser, without any thinking you can browse a file using the following keys:

Key Meaning
Left Move one column to the left (previous field)
Right Move one column to the right (next field)
Up Move up one row (previous record)
Down Move down one row (next record)
Page-Up Move to the previous screen
Page-Down Move to the next screen
Ctrl Page-Up Move to the top of the file
Ctrl Page-Down Move to the end of the file
Home Move to the leftmost visible column
End Move to the rightmost visible column
Ctrl Left Pan one column to the left
Ctrl Right Pan one column to the right
Ctrl Home Move to the leftmost column
Ctrl End Move to the rightmost column
Esc Terminate BROWSE()

On top of the screen you see a status line with the following indication:

Record ###/### Current record number / Total number of records.
<none> There are no records, the file is empty.
<new> You are in append mode at the bottom of file.
<Deleted> Current record is deleted.
<bof> You are at the top of file.

You should pass whole four valid coordinate, if less than four parameters are passed to BROWSE() the coordinate are default to: 1, 0, MAXROW(), MAXCOL().
Example(s)
// this one shows you how to browse around
USE Around
BROWSE()
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
DBEDIT()*,TBrowse class
Index
API

DBEDIT()*

Browse records in a table
Syntax
DBEDIT( [<nTop>], [<nLeft>], [<nBottom>], [<nRight>], [<acColumns>], [<xUserFunc>], [<xColumnSayPictures>], [<xColumnHeaders>], [<xHeadingSeparators>], [<xColumnSeparators>], [<xFootingSeparators>], [<xColumnFootings>] ) --> lOk
Argument(s)
<nTop> coordinate for top row display. <nTop> could range from 0 to MAXROW(), default is 0.
<nLeft> coordinate for left column display. <nLeft> could range from 0 to MAXCOL(), default is 0.
<nBottom> coordinate for bottom row display. <nBottom> could range from 0 to MAXROW(), default is MAXROW().
<nRight> coordinate for right column display. <nRight> could range from 0 to MAXCOL(), default is MAXCOL().
<acColumns> is an array of character expressions that contain database fields names or expressions to display in each column. If not specified, the default is to display all fields from the database in the current work area.
<xUserFunc> is a name of a user defined function or a code block that would be called every time unrecognized key is been pressed or when there are no keys waiting to be processed and DBEDIT() goes into idle mode. If <xUserFunc> is a character string, it must contain root name of a valid user define function without parentheses. Both the user define function or the code block should accept two parameters: nMode, nCurrentColumn. Both should return a numeric value that correspond to one of the expected return codes (see table below for a list of nMode and return codes).
<xColumnSayPictures> is an optional picture. If <xColumnSayPictures> is a character string, all columns would used this value as a picture string. If <xColumnSayPictures> is an array, each element should be a character string that correspond to a picture string for the column with the same index. Look at the help for @...SAY to get more information about picture values.
<xColumnHeaders> contain the header titles for each column, if this is a character string, all columns would have that same header, if this is an array, each element is a character string that contain the header title for one column. Header may be split to more than one line by placing semicolon (;) in places where you want to break line. If omitted, the default value for each column header is taken from <acColumns> or field name if <acColumns> was not specified.
<xHeadingSeparators> is an array that contain characters that draw the lines separating the headers and the fields data. Instead of an array you can use a character string that would be used to display the same line for all fields. Default value is a double line.
<xColumnSeparators> is an array that contain characters that draw the lines separating displayed columns. Instead of an array you can use a character string that would be used to display the same line for all fields. Default value is a single line.
<xFootingSeparators> is an array that contain characters that draw the lines separating the fields data area and the footing area. Instead of an array you can use a character string that would be used to display the same line for all footers. Default is to have to no footing separators.
<xColumnFootings> contain the footing to be displayed at the bottom of each column, if this is a character string, all columns would have that same footer, if this is an array, each element is a character string that contain the footer for one column. Footer may be split to more than one line by placing semicolon (;) in places where you want to break line. If omitted, no footer are displayed.
Returns
DBEDIT() return .F. if there is no database in use or if the number of columns to display is zero, else DBEDIT() return .T.
Description
DBEDIT() display and edit records from one or more work areas in a grid on screen. Each column is defined by element from <acColumns> and is the equivalent of one field. Each row is equivalent of one database record.
Following are active keys that handled by DBEDIT(): ---------------------------------------------------

Key Meaning
Left Move one column to the left (previous field)
Right Move one column to the right (next field)
Up Move up one row (previous record)
Down Move down one row (next record)
Page-Up Move to the previous screen
Page-Down Move to the next screen
Ctrl Page-Up Move to the top of the file
Ctrl Page-Down Move to the end of the file
Home Move to the leftmost visible column
End Move to the rightmost visible column
Ctrl Left Pan one column to the left
Ctrl Right Pan one column to the right
Ctrl Home Move to the leftmost column
Ctrl End Move to the rightmost column

When <xUserFunc> is omitted, two more keys are active:

Key Meaning
Esc Terminate BROWSE()
Enter Terminate BROWSE()

When DBEDIT() execute <xUserFunc> it pass the following arguments: nMode and the index of current record in <acColumns>. If <acColumns> is omitted, the index number is the FIELD() number of the open database structure.
DBEDIT() nMode could be one of the following: ---------------------------------------------

Dbedit.ch Meaning
DE_IDLE DBEDIT() is idle, all movement keys have been handled.
DE_HITTOP Attempt to cursor past top of file.
DE_HITBOTTOM Attempt to cursor past bottom of file.
DE_EMPTY No records in work area, database is empty.
DE_EXCEPT Key exception.

The user define function or code block must return a value that tell DBEDIT() what to do next.
User function return codes:
---------------------------

Dbedit.ch Value Meaning
DE_ABORT 0 Abort DBEDIT().
DE_CONT 1 Continue DBEDIT() as is.
DE_REFRESH 2 Force reread/redisplay of all data rows.

The user function is called once in each of the following cases: - The database is empty. - The user try to move past top of file or past bottom file. - Key exception, the uses had pressed a key that is not handled by DBEDIT(). - The keyboard buffer is empty or a screen refresh had just occurred DBEDIT() is a compatibility function, it is superseded by the TBrowse class and there for not recommended for new applications.
Example(s)
// Browse a file using default values
USE Test
DBEDIT()
Status
Started
Compliance
Unknown 'COMPLIANCE' code: '<xUserFunc> can take a code block value, this is a Harbour extension.
CA-Cl*pper will throw an error if there's no database open, Harbour would return .F.
CA-Cl*pper is buggy and will throw an error if the number of columns is zero, Harbour would return .F.
The CA-Cl*pper 5.2 NG state that the return value is NIL, this is wrong and should be read logical.
There is an undocumented result code (3) from the user defined function in CA-Cl*pper (both 87 and 5.x). This is an Append Mode which: "split the screen to allow data to be appended in windowed area". This mode is not supported by Harbour.'
File(s)
Header files are dbedit.ch, inkey.ch Library is rtl
See also
@...SAY,BROWSE(),TBrowse class,TRANSFORM()
Index
API

HB_KEYPUT()

Put an inkey code to the keyboard buffer.
Syntax
HB_KEYPUT( <nInkeyCode> )
Argument(s)
<nInkeyCode> is the inkey code, which should be inserted into the keyboard buffer.
Returns
There is no return value.
Description
Inserts an inkey code to the string buffer. The buffer is *not* cleared in this operation. This function allows to insert such inkey codes which are not in the range of 0 to 255. To insert more than one code, call the function repeatedly. The zero code cannot be inserted.
Example(s)
// Stuff an Alt+PgDn key into the keyboard buffer
HB_KEYPUT( K_ALT_PGDN )
Test(s)
HB_KEYPUT( K_ALT_PGDN ) ; ? INKEY() ==> 417
HB_KEYPUT( K_F11 ) ; ? INKEY() ==> -40
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
KEYBOARD,CLEAR TYPEAHEAD,INKEY()
Index
API

INKEY()

Extracts the next key code from the Harbour keyboard buffer.
Syntax
INKEY( [<nTimeout>] [,<nEvents>] ) --> nKey
Argument(s)
<nTimeout> is an optional timeout value in seconds, with a granularity of 1/10th of a second. If omitted, INKEY() returns immediately. If set to 0, INKEY() waits until an input event occurs. If set to any other value, INKEY() will return either when an input event occurs or when the timeout period has elapsed. If only this parameter is specified and it is not numeric, it will be treated as if it were 0. But if both parameters are specified and this parameter is not numeric, it will be treated as if it were not present.
<nEvents> is an optional mask of input events that are to be enabled. If omitted, defaults to hb_set.HB_SET_EVENTMASK. Valid input masks are in inkey.ch and are explained below. It is recommended that the mask names be used rather than their numeric values, in case the numeric values change in future releases of Harbour. To allow more than one type of input event, simply add the various mask names together.

inkey.ch Meaning
INKEY_MOVE Mouse motion events are allowed
INKEY_LDOWN The mouse left click down event is allowed
INKEY_LUP The mouse left click up event is allowed
INKEY_RDOWN The mouse right click down event is allowed
INKEY_RUP The mouse right click up event is allowed
INKEY_KEYBOARD All keyboard events are allowed
INKEY_ALL All mouse and keyboard events are allowed
HB_INKEY_EXTENDED Extended keyboard codes are used.

If the parameter is not numeric, it will be treated as if it were set to hb_set.HB_SET_EVENTMASK.
Returns
0 in case of timeout with no input event, otherwise returns a value in the range -47 to 386 for keyboard events or the range 1001 to 1007 for mouse events. Mouse events and non-printable keyboard events are represented by the K_<event> values listed in inkey.ch. Keyboard event return codes in the range 32 through 127 are equivalent to the printable ASCII character set. Keyboard event return codes in the range 128 through 255 are assumed to be printable, but results may vary based on hardware and nationality. If HB_INKEY_EXTENDED mode is used, then the return value for keyboard events ranges from 1 through 767 and 1077 through 1491, although not all codes are used.
Extended key codes consist of the PC keyboard scan code and one or more offset values. If no keyboard modifier was used, then HB_INKEY_NONE is added. The Alt key adds HB_INKEY_ALT, the Ctrl key adds HB_INKEY_CTRL, the Shift key adds HB_INKEY_SHIFT, and enhanced keys (KeyPad+/ and CursorPad keys) add HB_INKEY_ENHANCED. For example, F1 is scan code 59, so if you just press F1, you get key code 315, but Alt+F1 gives 443, Ctrl+F1 gives 571, and Shift+ F1 gives 699. And NumPad+/ gives 1077, 1205, 1333, and 1461. At this time, the only value that can combine with other values is HB_INKEY_ENHANCED (i.e., there are no Alt+Ctl combinations, etc.)
Note: The extended key code set is larger than the normal key code set. As a result, if you switch between the normal and extended modes, you need to be aware that some codes get translated into a zero in normal mode (because there is no corresponding code in normal mode) and that these codes get removed from the keyboard input buffer in normal mode and you won't be able to go back and fetch them later in extended mode.
Description
INKEY() can be used to detect input events, such as keypress, mouse movement, or mouse key clicks (up and/or down).
Example(s)
// Wait for the user to press the Esc key
? "Please press the ESC key."
WHILE INKEY( 0.1 ) != K_ESC
END
Test(s)
KEYBOARD "AB"; ? INKEY(), INKEY() ==>   65   66
Status
Started
Compliance
Unknown 'COMPLIANCE' code: 'INKEY() is compliant with the CA-Cl*pper 5.3 INKEY() function with one exception: The Harbour INKEY() function will raise an argument error if the first parameter is less than or equal to 0 and the second parameter (or the default mask) is not valid, because otherwise INKEY would never return, because it was, in effect, asked to wait forever for no events (Note: In CA-Cl*pper, this also blocks SET KEY events).'
File(s)
Library is rtl
See also
inkey.ch
Index
API

LASTKEY()

Get the last key extracted from the keyboard buffer.
Syntax
LASTKEY( [<nInputMask>] ) --> nKey
Argument(s)
nInputMask is an optional integer value composed of one or more INKEY_ or HB_INKEY_ constants. The sole purpose of this argument is to allow switching between using HB_INKEY_EXTENDED key codes and using the normal CA-Cl*pper-compatible key codes
Returns
<nKey> The last key extracted from the keyboard buffer.
Description
Returns the value of the last key exttracted from the Harbour keyboard buffer
Example(s)
// Continue looping unless the ESC key was pressed in MainFunc()
WHILE TRUE
MainFunc()
IF LASTKEY() == K_ESC
EXIT
ENDIF
END WHILE
Test(s)
KEYBOARD "AB"; ? INKEY(), LASTKEY() ==>   65   65
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'LASTKEY() is compliant with CA-Cl*pper 5. 3, but has been extended for Harbour.'
File(s)
Library is rtl
See also
INKEY(),LASTKEY()
Index
API

MCOL()

Returns the mouse cursor column position.
Syntax
MCol() --> nMouseColumn
Argument(s)
None
Returns
<nMouseColumn> The mouse cursor column position.
Description
This function returns the column position of the mouse cursor. On graphical systems the value represents pixels. On character-based systems the value represents character columns as in CA-Cl*pper.
Example(s)
IF MCol() < 1
? "Mouse is on left edge!"
ENDIF
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'MCOL() is compliant with CA-Cl*pper 5.3, but has been extended to work on graphical systems as well as character-based systems.'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
MROW()
Index
API

MENU TO

Invoked a menu defined by set of @...PROMPT
Syntax
MENU TO <cVariable>
Argument(s)
<cVariable> is a character string that contain the name of the variable to hold the menu choices, if this variable does not exist a PRIVATE variable with the name <cVariable> would be created to hold the result.
Description
Menu To() invoked the menu define by previous __AtPrompt() call and display a highlight bar that the user can move to select an option from the menu. If <cVariable> does not exist or not visible, a PRIVATE variable named <cVariable> is created and hold the current menu selection. If there is a variable named <cVariable>, its value is used to select the first highlighted item.
Menu prompts and messages are displayed in current Standard color, highlighted bar is displayed using current Enhanced color.
Pressing the arrow keys move the highlighted bar. When a menu item is highlighted the message associated with it is displayed on the line specified with SET MESSAGE. If SET WRAP is ON and the user press UP arrow while on the first selection the last menu item is highlighted, if the user press Down arrow while on the last item, the first item is highlighted.
Following are active keys that handled by Menu To:

key Meaning
Up - Move to previous item
Down - Move to next item
Left - Move to previous item
Right - Move to next item
Home - Move to the first item
End - Move to the last item
Page-Up - Select menu item, return position
Page-Down - Select menu item, return position
Enter - Select menu item, return position
Esc - Abort selection, return 0
First letter - Select next menu with the same first letter,
| return this item position.

upon exit the cursor is placed at MAXROW()-1, 0 Menu To can be nested without loosing the previous prompts.
MENU TO command is preprocessed into __MenuTo() function during compile time.
Example(s)
// display menu item on each screen corner and let user select one
CLS
SET MESSAGE TO MAXROW()/2 CENTER
SET WRAP ON
@ 0,         0           PROMPT "1. Upper left"   MESSAGE " One "
@ 0,         MAXCOL()-16 PROMPT "2. Upper right"  MESSAGE " Two "
@ MAXROW()-1,MAXCOL()-16 PROMPT "3. Bottom right" MESSAGE "Three"
@ MAXROW()-1,0           PROMPT "4. Bottom left"  MESSAGE "Four "
MENU TO nChoice
SETPOS ( MAXROW()/2, MAXCOL()/2 - 10 )
if nChoice == 0
?? "Esc was pressed"
else
?? "Selected option is", nChoice
endif
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
See also
@...PROMPT,ACHOICE(),SET MESSAGE,SET INTENSITY,SET WRAP,__ATPROMPT()
Index
API

MROW()

Returns the mouse cursor row position.
Syntax
MRow() --> nMouseRow
Argument(s)
None
Returns
<nMouseRow> The mouse cursor row position.
Description
This function returns the current mouse row cursor position. On graphical systems the value represents pixel rows. On character-based systems the value represents character rows as in CA-Cl*pper.
Example(s)
IF MRow() < 1
? "Mouse is on top row!"
ENDIF
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'MROW() is compliant with CA-Cl*pper 5.3, but has been extended to work on graphical systems as well as character-based systems.'
File(s)
Library is rtl
See also
MCOL()
Index
API

NEXTKEY()

Get the next key code in the buffer without extracting it.
Syntax
NEXTKEY( [<nInputMask>] ) --> nKey
Argument(s)
nInputMask is an optional integer value composed of one or more INKEY_ or HB_INKEY_ constants. The sole purpose of this argument is to allow switching between using HB_INKEY_EXTENDED key codes and using the normal CA-Cl*pper-compatible key codes
Returns
<nKey> The value of the next key in the Harbour keyboard buffer.
Description
Returns the value of the next key in the Harbour keyboard buffer without extracting it.
Example(s)
// Use NEXTKEY() with INKEY() to change display characters, or by
// itself to exit the loop, so that the caller can detect the Esc.
LOCAL nKey, cChar := "+"
WHILE TRUE
?? cChar
nKey := NEXTKEY()
IF nKey == K_ESC
EXIT
ELSE
IF nKey != 0
cChar := CHR( nKey )
END IF
END IF
END WHILE
Test(s)
KEYBOARD "AB"; ? NEXTKEY(), NEXTKEY() ==>   65   65
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'NEXTKEY() is compliant with CA-Cl*pper 5. 3, but has been extended for Harbour.'
File(s)
Library is rtl
See also
INKEY(),LASTKEY()
Index
API

OUTERR()

Write a list of values to the standard error device
Syntax
OUTERR( <xExp,...> )
Argument(s)
<xExp,...> is a list of expressions to display. Expressions are any mixture of Harbour data types.
Description
OUTERR() write one or more values into the standard error device. Character and Memo values are printed as is, Dates are printed according to the SET DATE FORMAT, Numeric values are converted to strings, Logical values are printed as .T. or .F., NIL are printed as NIL, values of any other kind are printed as empty string. There is one space separating each two values. Note that Numeric value can take varying length when converted into string depending on its source (see STR() for detail).
There is an undocumented CA-Cl*pper command line switch //STDERR which can set the file handle to write output from OUTERR(). If not specified the default STDERR is used, //STDERR or //STDERR:0 set OUTERR() to output to the same file handle as OUTSTD(), //STDERR:n set output to file handle n. Like other undocumented features this switch is available only if src/rtl/console.c was compiled with the HB_CLP_UNDOC flag.
Example(s)
// write error log information
OUTERR( DATE(), TIME(), "Core meltdown detected" )
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
?,??,DEVOUT(),DEVOUTPICT(),DISPOUT(),DISPOUTAT(),OUTSTD(),QOUT(), QQOUT(),STR()
Index
API

OUTSTD()

Write a list of values to the standard output device
Syntax
OUTSTD( <xExp,...> )
Argument(s)
<xExp,...> is a list of expressions to display. Expressions are any mixture of Harbour data types.
Description
OUTSTD() write one or more values into the standard output device. Character and Memo values are printed as is, Dates are printed according to the SET DATE FORMAT, Numeric values are converted to strings, Logical values are printed as .T. or .F., NIL are printed as NIL, values of any other kind are printed as empty string. There is one space separating each two values. Note that Numeric value can take varying length when converted into string depending on its source (see STR() for detail).
OUTSTD() is similar to QQOUT() with the different that QQOUT() send its output to the Harbour console stream, which can or can not be redirected according with the screen driver, and OUTSTD() send its output to the standard output device (STDOUT) and can be redirected.
Example(s)
OUTSTD( "Hello" )            // Result: Hello
OUTSTD( 1, .T., NIL, "A" )
OUTSTD( "B" )                // Result:          1 .T. NIL AB
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
?,??,DEVOUT(),DEVOUTPICT(),DISPOUT(),DISPOUTAT(),OUTERR(),QOUT(), QQOUT(),STR()
Index
API

READKEY()*

Determine which key terminated a READ.
Syntax
READKEY() --> nKeyCode
Argument(s)
None.
Returns
READKEY() returns a numeric code representing the key that caused READ to terminate.
Description
READKEY() is used after a READ was terminated to determine the exit key pressed. If the GET buffer was updated during READ, 256 is added to the return code.

Exit Return code Return code
Key (not updated) (updated)
Up 4 260
Down 5 261
Page-Up 6 262
Page-Down 7 263
Ctrl Page-Up 34 290
Ctrl Page-Down 35 291
Esc 12 268
Ctrl End 14 270
Enter 15 271
Key >= 32 15 271
otherwise 0 0

READKEY() is a compatibility function so try not to use it. READKEY() is superseded by LASTKEY() which returns the INKEY() code for that key. UPDATED() could be used to find if the GET buffer was changed during the READ.
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'READKEY() is compliant with CA-Cl*pper 5. 3'
File(s)
Library is rtl
See also
@...GET,INKEY(),LASTKEY(),READ,READEXIT(),UPDATED()
Index
API

READVAR()

Return variable name of current GET or MENU
Syntax
READVAR( [<cVarName>] ) --> cOldVarName
Argument(s)
<cVarName> is a new variable name to set.
Returns
READVAR() return the old variable name. If no variable previously was set, READVAR() return "".
Description
READVAR() is set inside a READ or MENU TO command to hold the uppercase name of the GET / MENU TO variable, and re-set back to old value when those commands finished. You should not normally set a variable name but rather use it to retrieve the name of a GET variable when executing a VALID or WHEN clause, or during SET KEY execution and you are inside a READ or MENU TO.
Example(s)
// display a menu, press F1 to view the MENU TO variable name
CLS
@ 1, 10 PROMPT "blood sucking insect that infect beds   "
@ 2, 10 PROMPT "germ; virus infection                   "
@ 3, 10 PROMPT "defect; snag; (source of) malfunctioning"
@ 4, 10 PROMPT "small hidden microphone                 "
@ 6, 10 SAY "(Press F1 for a hint)"
SET KEY 28 TO ShowVar
MENU TO What_Is_Bug
PROCEDURE ShowVar
ALERT( READVAR() )        // WHAT_IS_BUG in red ALERT() box
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'READVAR() works exactly like CA-Cl*pper's READKEY().
Note however, that the <cVarName> parameter is not documented and used internally by CA-Cl*pper.'
Platform(s)
This is available on all platforms
File(s)
Library is rtl
See also
@...GET,@...PROMPT,MENU TO,READ,SET KEY,__AtPrompt(),__MenuTo()
Index
API

TBrowseDB()

Create a new TBrowse object to be used with database file
Syntax
TBrowseDB( [<nTop>], [<nLeft>], [<nBottom>], [<nRight>] ) --> oBrowse
Argument(s)
<nTop> coordinate for top row display.
<nLeft> coordinate for left column display.
<nBottom> coordinate for bottom row display.
<nRight> coordinate for right column display.
Returns
TBrowseDB() return new TBrowse object with the specified coordinate and a default :SkipBlock, :GoTopBlock and :GoBottomBlock to browse a database file.
Description
TBrowseDB() is a quick way to create a TBrowse object along with the minimal support needed to browse a database. Note that the returned TBrowse object contain no TBColumn objects and you need to add column for each field by your self.
Example(s)
for a good example, look at the source code for BROWSE() function
at src/rtl/browse.prg
Status
Started
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
BROWSE(),TBColumn class,TBrowse class,TBrowseNew()
Index
API

__AtPrompt()

Display a menu item on screen and define a message
Syntax
__AtPrompt( <nRow>, <nCol>, <cPrompt>, [<xMsg>] ) --> .F.
Argument(s)
<nRow> is the row number to display the menu <cPrompt>. Value could range from zero to MAXROW().
<nCol> is the column number to display the menu <cPrompt>. Value could range from zero to MAXCOL().
<cPrompt> is the menu item character string to display.
<xMsg> define a message to display each time this menu item is highlighted. <xMsg> could be a character string or code block that is evaluated to a character string. If <xMsg> is not specified or of the wrong type, an empty string ("") would be used.
Returns
__AtPrompt() always return .F.
Description
With __AtPrompt() you define and display a menu item, each call to __AtPrompt() add another item to the menu, to start the menu itself you should call the __MenuTo() function (MENU TO command). You can define any row and column combination and they will be displayed at the order of definition. After each call to __AtPrompt(), the cursor is placed one column to the right of the last text displayed, and ROW() and COL() are updated.
@...PROMPT command is preprocessed into __AtPrompt() function during compile time.
Example(s)
// display a two line menu with status line at the bottom
// let the user select favorite day
SET MESSAGE TO 24 CENTER
@ 10, 2 PROMPT "Sunday" MESSAGE "This is the 1st item"
@ 11, 2 PROMPT "Monday" MESSAGE "Now we're on the 2nd item"
MENU TO nChoice
DO CASE
CASE nChoice == 0           // user press Esc key
QUIT
CASE nChoice == 1           // user select 1st menu item
? "Guess you don't like Mondays"
CASE nChoice == 2           // user select 2nd menu item
? "Just another day for some"
ENDCASE
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant except that menus (internally arrays) in Harbour can have an unlimited number of elements
File(s)
Library is rtl
See also
ACHOICE(),MENU TO,SET MESSAGE,SET INTENSITY,SET WRAP,__MENUTO()
Index
API

__INPUT()

Stops application
Syntax
__INPUT( <cMessage> ) --> <cString>
Argument(s)
<cMessage> is any valid expression.
Returns
<cString> input value macroed
Description
This function waits for a console input and returns macroed expression entered.
Status
Started
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
__WAIT(),__ACCEPT()
Index
API

__KEYBOARD()

DO NOT CALL THIS FUNCTION DIRECTLY!
Syntax
KEYBOARD <cString> CLEAR TYPEAHEAD
Argument(s)
<cString> is the optional string to stuff into the Harbour keyboard buffer after clearing it first.
Note: The character ";" is converted to CHR(13) (this is an undocumented CA-Cl*pper feature).
Description
Clears the Harbour keyboard typeahead buffer and then inserts an optional string into it.
Example(s)
// Stuff an Enter key into the keyboard buffer
KEYBOARD CHR(13)
// Clear the keyboard buffer
CLEAR TYPEAHEAD
Test(s)
KEYBOARD CHR(13); ? INKEY() ==> 13
KEYBOARD ";" ? INKEY() ==> 13
KEYBOARD "HELLO"; CLEAR TYPEAHEAD; ? INKEY() ==> 0
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: '__KEYBOARD() is compliant with CA-Cl*pper 5.3'
File(s)
Library is rtl
See also
CLEAR TYPEAHEAD,KEYBOARD
Index
API

__MenuTo()

Invoked a menu defined by set of @...PROMPT
Syntax
__MenuTo( <bBlock>, <cVariable> ) --> nChoice
Argument(s)
<bBlock> is a set/get code block for variable named <cVariable>.
<cVariable> is a character string that contain the name of the variable to hold the menu choices, if this variable does not exist a PRIVATE variable with the name <cVariable> would be created to hold the result.
Returns
__MenuTo() return the number of select menu item, or 0 if there was no item to select from or if the user pressed the Esc key.
Description
__MenuTo() invoked the menu define by previous __AtPrompt() call and display a highlight bar that the user can move to select an option from the menu. If <cVariable> does not exist or not visible, a PRIVATE variable named <cVariable> is created and hold the current menu selection. If there is a variable named <cVariable>, its value is used to select the first highlighted item.
Menu prompts and messages are displayed in current Standard color, highlighted bar is displayed using current Enhanced color.
Pressing the arrow keys move the highlighted bar. When a menu item is highlighted the message associated with it is displayed on the line specified with SET MESSAGE. If SET WRAP is ON and the user press UP arrow while on the first selection the last menu item is highlighted, if the user press Down arrow while on the last item, the first item is highlighted.
Following are active keys that handled by __MenuTo():

key Meaning
Up Move to previous item
Down Move to next item
Left Move to previous item
Right Move to next item
Home Move to the first item
End Move to the last item
Page-Up Select menu item, return position
Page-Down Select menu item, return position
Enter Select menu item, return position
Esc Abort selection, return 0
First letter Select next menu with the same first letter,
| return this item position.

upon exit the cursor is placed at MAXROW()-1, 0 __MenuTo() can be nested without loosing the previous prompts.
MENU TO command is preprocessed into __MenuTo() function during compile time.
Example(s)
// display menu item on each screen corner and let user select one
CLS
SET MESSAGE TO MAXROW()/2 CENTER
SET WRAP ON
@ 0,         0           PROMPT "1. Upper left"   MESSAGE " One "
@ 0,         MAXCOL()-16 PROMPT "2. Upper right"  MESSAGE " Two "
@ MAXROW()-1,MAXCOL()-16 PROMPT "3. Bottom right" MESSAGE "Three"
@ MAXROW()-1,0           PROMPT "4. Bottom left"  MESSAGE "Four "
MENU TO nChoice
SETPOS ( MAXROW()/2, MAXCOL()/2 - 10 )
if nChoice == 0
?? "Esc was pressed"
else
?? "Selected option is", nChoice
endif
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
@...PROMPT,ACHOICE(),SET MESSAGE,SET INTENSITY,SET WRAP,__ATPROMPT()
Index
API

__NONOALERT()

Override //NOALERT command line switch
Syntax
__NONOALERT()
Argument(s)
This function takes no arguments.
Description
The //NOALERT command line switch cause Clipper to ignore calls to the ALERT() function, this function override this behavior and always display ALERT() dialog box.
Example(s)
// make sure alert are been displayed
__NONOALERT()
Status
Ready
Compliance
This is an undocumented CA-Cl*pper v5.2 function and is only visible if source was compiled with the HB_C52_UNDOC flag
File(s)
Library is rtl
Index
API

__XRestScreen()

Restore screen image and coordinate from an internal buffer
Syntax
__XRestScreen()
Argument(s)
none.
Description
__XRestScreen() restore saved image of the whole screen from an internal buffer that was saved by __XSaveScreen(), it also restore cursor position. After a call to __XRestScreen() the internal buffer is cleared.
RESTORE SCREEN command is preprocessed into __XRestScreen() function during compile time. Note that RESTORE SCREEN FROM is preprocessed into RESTSCREEN() function.
__XRestScreen() is a compatibility function, it is superseded by RESTSCREEN() which allow you to restore the screen from a variable.
Example(s)
// save the screen, display list of files than restore the screen
SAVE SCREEN
DIR *.*
WAIT
RESTORE SCREEN
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This part of the GT API and supported only by some platforms.
File(s)
Library is rtl
See also
__XRESTSCREEN(),SAVE SCREEN,__XSAVESCREEN()
Index
API

__XSaveScreen()

Save whole screen image and coordinate to an internal buffer
Syntax
__XSaveScreen()
Argument(s)
none.
Description
__XSaveScreen() save the image of the whole screen into an internal buffer, it also save current cursor position. The information could later be restored by __XRestScreen(). Each call to __XSaveScreen() overwrite the internal buffer.
SAVE SCREEN command is preprocessed into __XSaveScreen() function during compile time. Note that SAVE SCREEN TO is preprocessed into SAVESCREEN() function.
__XSaveScreen() is a compatibility function, it is superseded by SAVESCREEN() which allow you to save part or all the screen into a variable.
Example(s)
// save the screen, display list of files than restore the screen
SAVE SCREEN
DIR *.*
WAIT
RESTORE SCREEN
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
Platform(s)
This part of the GT API and supported only by some platforms.
File(s)
Library is rtl
See also
RESTORE SCREEN,RESTSCREEN(),SAVESCREEN()
Index
API

dbSkipper()

Helper function to skip a database
Syntax
dbSkipper( <nRecs> ) --> nSkipped
Argument(s)
<nRecs> is the number of records to skip relative to current record. Positive number would try to move the record pointer forward, while a negative number would try to move the record pointer back <nRecs> records.
Returns
dbSkipper() return the number of actual record skipped.
Description
dbSkipper() is a helper function used in browse mechanism to skip a number of records while giving the caller indication about the actual records skipped.
Example(s)
// open a file and find if we've got enough records in it
USE MonthSales
IF dbSkipper( 100 ) == 100
? "Good work! You can party now"
ELSE
? "Too bad, you should really work harder"
ENDIF
CLOSE
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'XPP'
File(s)
Library is rtl
See also
DBSKIP(),SKIP
Index
API

Variable management

EMPTY()

Checks if the passed argument is empty.
Syntax
EMPTY( <xExp> ) --> lIsEmpty
Argument(s)
<xExp> is any valid expression.
Returns
A logical value. It is true (.T.) if the passed argument is empty otherwise it is false (.F.).
Description
This function checks if an expression has empty value and returns a logical indicating whether it the expression is empty or not.
Example(s)
? EMPTY( "I'm not empty" )    // .F.
Test(s)
FUNCTION Test()
? EMPTY( NIL )             // .T.
? EMPTY( 0 )               // .T.
? EMPTY( .F. )             // .T.
? EMPTY( "" )              // .T.
? EMPTY( 1 )               // .F.
? EMPTY( .T. )             // .F.
? EMPTY( "smile" )         // .F.
? EMPTY( Date() )          // .F.
RETURN NIL
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
LEN()
Index
API

HB_ISBYREF()

Determine if a variable is passed by reference.
Syntax
HB_ISBYREF( @<Var> ) --> <lVarIsByRef>
Argument(s)
@<Var> is the variable to test; it must be passed by reference.
Returns
<lVarIsByRef> a logical value indicating if the variable is passed by reference to actual function or procedure.
Description
This function return a logical value indicating if the variable is passed by reference to actual function or procedure.
ATTENTION: The variable to test must be passed by reference. If the variable is not passed by reference, the function return NIL. This function is based on the form that Harbour manages to the variables for reference. When a variable is passed by reference, what receives the function or procedure is, a pointer to the previous variable, be this the container variable of the data or a pointer to another variable. The function observes if the variable passed points to a common variable or to a variable passed by reference.
Example(s)
See Tests
Test(s)
function Main()
local cVar := "Test local"
private nVar := 0
Test( @cVar, @nVar, cVar, nVar )
return nil
procedure Test( Arg1, Arg2, Arg3, Arg4 )
? hb_isbyref( @Arg1 )        // .T.
? hb_isbyref( @Arg2 )        // .T.
? hb_isbyref( @Arg3 )        // .F.
? hb_isbyref( @Arg4 )        // .F.
return
Status
Started
Compliance
This is Harbour specific
File(s)
Library is rtl
See also
VALTYPE()
Index
API

LEN()

Returns size of a string or size of an array.
Syntax
LEN( <cString> | <aArray> ) --> <nLength>
Argument(s)
<acString> is a character string or the array to check.
Returns
The length of the string or the number of elements that contains an array.
Description
This function returns the string length or the size of an array or the size of a hash table. If it is used with a multidimensional array it returns the size of the first dimension.
Example(s)
? LEN( "Harbour" )           // 7
? LEN( { "One", "Two" } )    // 2
Test(s)
function Test()
LOCAL cName := ""
ACCEPT "Enter your name: " TO cName
? LEN( cName )
return nil
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
EMPTY(),RTRIM(),LTRIM(),AADD(),ASIZE()
Index
API

MEMVARBLOCK()

Returns a codeblock that sets/gets a value of memvar variable
Syntax
MEMVARBLOCK( <cMemvarName> ) --> <bBlock>
Argument(s)
<cMemvarName> - a string that contains the name of variable
Returns
<bBlock> a codeblock that sets/get the value of variable
Description
This function returns a codeblock that sets/gets the value of PRIVATE or PUBLIC variable. When this codeblock is evaluated without any parameters passed then it returns the current value of given variable. If the second parameter is passed for the codeblock evaluation then its value is used to set the new value of given variable - the passed value is also returned as a value of the codeblock evaluation.
Example(s)
PROCEDURE MAIN()
LOCAL cbSetGet
PUBLIC xPublic
cbSetGet = MEMVARBLOCK( "xPublic" )
EVAL( cbSetGet, "new value" )
? "Value of xPublic variable", EVAL( cbSetGet )
RETURN
Status
Ready
Compliance
This is CA-Cl*pper v5.2 compliant
File(s)
Library is rtl
See also
__MVGET(),__MVPUT()
Index
API

TYPE()

Retrieves the type of an expression
Syntax
TYPE( <cExp> ) --> <cRetType>
Argument(s)
<cExp> must be a character expression.
Returns
<cRetType> a string indicating the type of the passed expression.

<cRetType> Meaning
"A" Array
"B" Block
"C" Character (string)
"D" Date
"L" Logical
"M" Memo
"N" Numeric
"O" Object
"P" Pointer
"S" Symbol
"U" NIL, local or static variable, or not linked-in function
"UE" syntax error in the expression or invalid arguments
"UI" function with non-reserved name was requested

Description
This function returns a string which represents the data type of the argument. The argument can be any valid Harbour expression. If there is a syntax error in passed expression then "UE" is returned. If there is a call for any non-reserved Harbour function then "UI" is returned (in other words there is no call for passed UDF function during a data type determination - this is CA-Cl*pper compatible behavior). Additionally if requested user defined function is not linked into executable then "U" is returned.
The data type of expression is checked by invoking a macro compiler and by evaluation of generated code (if there is no syntax errors). This causes that TYPE() cannot determine a type of local or static variables - only symbols visible at runtime can be checked.
Notice the subtle difference between TYPE and VALTYPE functions. VALTYPE() function doesn't call a macro compiler - it simply checks the type of passed argument of any type. TYPE() requires a string argument with a valid Harbour expression - the data type of this expression is returned.
Example(s)
? TYPE( "{ 1, 2 }" )                            //prints "A"
? TYPE( "IIF(.T., SUBSTR('TYPE',2,1), .F.)" )   //prints "C"
? TYPE( "AT( 'OK', MyUDF())>0" )                //prints "UI"
? TYPE( "{ 1, 2 }[ 5 ]" )                       //prints "UE"
//--------------------------------------------------------
LOCAL c
PRIVATE a:="A", b:="B"
? TYPE( "a + b + c" )     //prints: "U" ('C' variable is a local one)
//--------------------------------------------------------
LOCAL cFilter := SPACE( 60 )
ACCEPT "Enter filter expression:" TO cFilter
IF( TYPE( cFilter ) $ "CDLMN" ) )
// this is a valid expression
SET FILTER TO &cFilter
ENDIF
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: '- Incompatibility with CA-Cl*pper:
In the following code:
PRIVATE lCond := 0 ? TYPE( "IIF( lCond, 'true', MyUDF() )" )
CA-Cl*pper will print "UE" - in Harbour the output will be "UI"
- If "UI" is returned then the syntax of the expression is
correct. However invalid arguments can be passed to function/procedure that will cause runtime errors during evaluation of expression.
- Harbour supports two new types (Pointer and Symbol) which does
not exists in CA-Cl*pper.'
File(s)
Library is rtl
See also
VALTYPE()
Index
API

VALTYPE()

Retrieves the data type of an expression
Syntax
VALTYPE( <xExp> ) --> <cRetType>
Argument(s)
<xExp> is any valid expression.
Returns
<cRetType> a character indicating the type of the passed expression.

<cRetType> Meaning
"A" Array
"B" Block
"C" Character (string)
"D" Date
"L" Logical
"M" Memo
"N" Numeric
"O" Object
"P" Pointer
"S" Symbol
"U" NIL

Description
This function returns one character which represents the data type of the argument.
Example(s)
See Test(s)
Test(s)
function Test()
? ValType( Array( 1 ) )   // "A"
? ValType( {|| 1 + 1 } )  // "B"
? ValType( "HARBOUR" )    // "C"
? ValType( Date() )       // "D"
? ValType( .T. )          // "L"
? ValType( 1 )            // "N"
? ValType( TBrowse() )    // "O"
? ValType( hb_idleadd() ) // "P" Harbour extension
? ValType( @QOut() )      // "S" Harbour extension
? ValType( NIL )          // "U"
return nil
Status
Ready
Compliance
Unknown 'COMPLIANCE' code: 'VALTYPE() is CA-Cl*pper compliant, with the addition of the new Harbour types: Pointer and Symbol.'
File(s)
Library is rtl
See also
TYPE()
Index
API

__MVCLEAR()

This function releases all PRIVATE and PUBLIC variables
Syntax
__MVCLEAR()
Argument(s)
None
Returns
Nothing
Description
This function releases all PRIVATE and PUBLIC variables. It is used to implement CLEAR MEMORY statement. The memory occupied by all visible variables are released - any attempt to access the variable will result in a runtime error. You have to reuse PRIVATE or PUBLIC statement to create again the variable that was cleared by this function.
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
See also
__MVPUBLIC()
Index
API

__MVEXIST()

Determine if a given name is a PUBLIC or PRIVATE memory variable
Syntax
__MVEXIST( <cVarName> ) --> <lVariableExist>
Argument(s)
<cVarName> - string that specifies the name of variable to check
Returns
__MVEXIST() return TRUE (.T.) if a MEMVAR named <cVarName> exist.
Description
This function determine if a PUBLIC or PRIVATE variable with the name <cVarName> exist or not.
Example(s)
LOCAL   TheLocal
STATIC  TheStatic
PUBLIC  ThePublic
PRIVATE ThePrivate
? __MVEXIST( "NotExist"   )        // .F.
? __MVEXIST( "TheLocal"   )        // .F.
? __MVEXIST( "TheStatic"  )        // .F.
? __MVEXIST( "ThePublic"  )        // .T.
? __MVEXIST( "ThePrivate" )        // .T.
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
See also
MEMVAR, PRIVATE, PUBLIC
Index
API

__MVGET()

This function returns value of memory variable
Syntax
__MVGET( <cVarName> ) --> <xVar>
Argument(s)
<cVarName> - string that specifies the name of variable
Returns
<xVar> The value of variable
Description
This function returns the value of PRIVATE or PUBLIC variable if this variable exists otherwise it generates a runtime error. The variable is specified by its name passed as the function parameter.
Example(s)
FUNCTION MEMVARBLOCK( cMemvar )
RETURN {|x| ;
IIF( PCOUNT()==0, ;
__MVGET( cMemvar ),;
__MVPUT( cMemvar, x ) ) }
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
See also
__MVPUT()
Index
API

__MVPRIVATE()

This function creates a PRIVATE variable
Syntax
__MVPRIVATE( <variable_name> )
Argument(s)
<variable_name> = either a string that contains the variable's name or an one-dimensional array of strings with variable names No skeleton are allowed here.
Returns
Nothing
Description
This function can be called either by the harbour compiler or by user. The compiler always passes the item of IT_SYMBOL type that stores the name of variable. If a variable with the same name exists already then the value of old variable is hidden until the new variable is released. The new variable is always initialized to NIL value.
Example(s)
None Avaliable
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
Index
API

__MVPUBLIC()

This function creates a PUBLIC variable
Syntax
__MVPUBLIC( <variable_name> )
Argument(s)
<variable_name> = either a string that contains the variable's name or an one-dimensional array of strings with variable names No skeleton are allowed here.
Returns
Nothing
Description
This function can be called either by the harbour compiler or by user. The compiler always passes the item of IT_SYMBOL type that stores the name of variable. If a variable with the same name exists already then the new variable is not created - the previous value remains unchanged. If it is first variable with this name then the variable is initialized with .T. value.
Example(s)
None Avaliable
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
Index
API

__MVPUT()

This function set the value of memory variable
Syntax
__MVGET( <cVarName> [, <xValue>] ) --> <xValue>
Argument(s)
<cVarName> - string that specifies the name of variable <xValue> - a value of any type that will be set - if it is not specified then NIL is assumed
Returns
<xValue> A value assigned to the given variable.
Description
This function sets the value of PRIVATE or PUBLIC variable if this variable exists otherwise it generates a runtime error. The variable is specified by its name passed as the function parameter. If a value is not specified then the NIL is assumed
Example(s)
FUNCTION MEMVARBLOCK( cMemvar )
RETURN {|x| ;
IIF( PCOUNT()==0, ;
__MVGET( cMemvar ),;
__MVPUT( cMemvar, x ) ) }
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
See also
__MVPUT()
Index
API

__MVRELEASE()

This function releases PRIVATE variables
Syntax
__MVRELEASE( <skeleton>, <include_exclude_flag> )
Argument(s)
<skeleton> = string that contains the wildcard mask for variables' names that will be released. Supported wildcards: '*' and '?' <include_exclude_flag> = logical value that specifies if variables that match passed skeleton should be either included in deletion (if .T.) or excluded from deletion (if .F.)
Returns
Nothing
Description
This function releases values stored in memory variables. It shouldn't be called directly, it should be placed into RELEASE ALL command. If the released variable is a PRIVATE variable then previously hidden variable with the same name becomes visible after exit from the procedure where released variable was created. If you access the released variable in the same function/procedure where it was created the the NIL value is returned. You can however assign a new value to released variable without any side effects. PUBLIC variables are not changed by this function.
Example(s)
None Avaliable
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
Index
API

__MVSCOPE()

If variable exists then returns its scope.
Syntax
__MVSCOPE( <cVarName> )
Argument(s)
<cVarName> = a string with a variable name to check
Returns
The symbolic values are defined in include/hbmemvar.ch HB_MV_NOT_FOUND =variable is not declared (not found in symbol table) HB_MV_UNKNOWN =if variable doesn't exist (but found in symbol table) HB_MV_ERROR =if information cannot be obtained (memory error or argument error) HB_MV_PUBLIC =for public variables HB_MV_PRIVATE_GLOBAL =for private variables declared outside of current function/procedure HB_MV_PRIVATE_LOCAL =for private variables declared in current function/procedure
Example(s)
PROCEDURE MAIN()
PUBLIC mPublic
PRIVATE mPrivateGlobal
CallProc()
? __mvScope( "mPrivateLocal" )      //HB_MV_UNKNOWN
RETURN
PROCEDURE CallProc()
PRIVATE mPrivateLocal
? __mvScope( "mPublic" )            //HB_MV_PUBLIC
? __mvScope( "mPrivateGlobal" )     //HB_MV_PRIVATE_GLOBAL
? __mvScope( "mPrivateLocal" )      //HB_MV_PRIVATE_LOCAL
? __mvScope( "mFindMe" )            //HB_MV_NOT_FOUND
IF( __mvScope( "mPublic" ) > HB_MV_ERROR )
? "Variable exists"
ELSE
? "Variable not created yet"
ENDIF
RETURN
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
See also
include/hbmemvar.ch
Index
API

__MVXRELEASE()

This function releases value stored in PRIVATE or PUBLIC variable
Syntax
__MVXRELEASE( <variable_name> )
Argument(s)
<variable_name> = either a string that contains the variable's name or an one-dimensional array of strings with variable names No skeleton are allowed here.
Returns
Nothing
Description
This function releases values stored in memory variable. It shouldn't be called directly, rather it should be placed into RELEASE command. If the released variable is a PRIVATE variable then previously hidden variable with the same name becomes visible after exit from the procedure where released variable was created. If you access the released variable in the same function/procedure where it was created the the NIL value is returned. You can however assign a new value to released variable without any side effects.
It releases variable even if this variable was created in different procedure
Example(s)
PROCEDURE MAIN()
PRIVATE mPrivate
mPrivate :="PRIVATE from MAIN()"
? mPrivate     //PRIVATE from MAIN()
Test()
? mPrivate     //PRIVATE from MAIN()
RETURN
PROCEDURE Test()
PRIVATE mPrivate
mPrivate :="PRIVATE from Test()"
? mPrivate           //PRIVATE from TEST()
RELEASE mPrivate
? mPrivate           //NIL
mPrivate :="Again in Test()"
RETURN
Status
Ready
Compliance
This is Harbour specific
File(s)
Library is vm
Index
API