Harbour Reference Guide

BinToDec()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Converts a binary value to decimal
Syntax
BinToDec( <cN> ) โ†’ cNr
Arguments
cN Number to be converted
Returns
cNr Number converted
Description
This function converts a string cN from an binary value to a numeric decimal value.
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

DecToBin()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Converts a decimal value to binary
Syntax
DecToBin( <cN> ) โ†’ cNr
Arguments
cN Number to be converted
Returns
cNr Number converted
Description
This function converts a string cN from an decimal value to an binary value.
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

DecToHexa()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Converts a decimal value to hexadecimal
Syntax
DecToHexa( <cN> ) โ†’ cNr
Arguments
cN Number to be converted
Returns
cNr Number converted
Description
This function converts a string cN from an decimal value to an hexadecimal value.
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

DecToOctal()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Converts a decimal value to octal
Syntax
DecToOctal( <cN> ) โ†’ cNr
Arguments
cN Number to be converted
Returns
cNr Number converted
Description
This function converts a string cN from an decimal value to an octal value.
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

HexaToDec()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Converts a hexadecimal value to decimal
Syntax
HexaToDec( <cN> ) โ†’ cNr
Arguments
cN Number to be converted
Returns
cNr Number converted
Description
This function converts a string cN from an hexadecimal value to a numeric decimal value.
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

IsBin()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Check if the value is a binary number
Syntax
IsBin( <cN> ) โ†’ cNr
Arguments
cN String to be checked
Returns
cNr .T. if the string is binary, otherwise .F.
Description
check if the passed string is a binary number or not
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

IsDec()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Check if the value is a Decimal Number
Syntax
IsDec( <cN> ) โ†’ cNr
Arguments
cN String to be checked
Returns
cNr .T. if the string is decimal; otherwise .F.
Description
check if the passed string is a decimal number or not
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

IsHexa()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Check if the value is a hexadecimal number
Syntax
IsHexa( <cN> ) โ†’ cNr
Arguments
cN String to be checked
Returns
cNr .T. if the string is hexadecimal; otherwise .F.
Description
check if the passed string is a hexadecimal number or not
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

IsOctal()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Check if the value is a octal number
Syntax
IsOctal( <cN> ) โ†’ cNr
Arguments
cN String to be checked
Returns
cNr .T. if the string is octal; otherwise .F.
Description
check if the passed string is a octal number or not
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

OctalToDec()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Converts a octal value to decimal
Syntax
OctalToDec( <cN> ) โ†’ cNr
Arguments
cN Number to be converted
Returns
cNr Number converted
Description
This function converts a string cN from an octal value to a numeric decimal value.
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Conversion Tools
See also

ADays()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Returns an array with the days names.
Syntax
ADays() โ†’ aDays
Arguments
None
Returns
aDays The array which holds the days names.
Description
This function returns an array with all the days names in the selected current language.
Examples
LOCAL aDays := ADays()
? aDays[ 1 ]  // --> Sunday
? aDays[ 1 ]  // --> Domingo (if the selected language is Spanish)
Status
Ready
Compliance
Harbour specific
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Date
See also

AMonths()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Returns an array with the months names.
Syntax
AMonths() โ†’ aMonths
Arguments
None
Returns
aMonths The array which holds the months names.
Description
This function returns an array with all the months names in the selected current language.
Examples
LOCAL aMonths := AMonths()
? aMonths[ 1 ]  // --> January
? aMonths[ 1 ]  // --> Enero (if the selected language is Spanish)
Status
Ready
Compliance
Harbour specific
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Date
See also

hbmisc_DaysInMonth()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Gets the days in a month.
Syntax
hbmisc_DaysInMonth( <dDate> ) โ†’ nDays
Arguments
dDate A valid date.
Returns
nDays The number of days of the month.
Description
This function returns the number of days of the given date month.
Examples
? hbmisc_DaysInMonth( hb_SToD( "20000101" ) )  // --> 31
? hbmisc_DaysInMonth( hb_SToD( "20000201" ) )  // --> 29
Status
Ready
Compliance
Harbour specific
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Date
See also

IsLeapYear()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Checks if the given date is a leap year.
Syntax
IsLeapYear( <dDate> ) โ†’ lTrueOrFalse
Arguments
dDate A valid date.
Returns
lTrueOrFalse A logical that indicates if the date year is leap
Description
This function returns true if the given date is a leap year and false if isn't.
Examples
? IsLeapYear( hb_SToD( "20000101" ) )  // --> .T.
? IsLeapYear( hb_SToD( "20010101" ) )  // --> .F.
Status
Ready
Compliance
Harbour specific
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Date
See also

WoY()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Gets the week number of the year.
Syntax
WoY( <dDate>, <lIso> ) โ†’ nWeek
Arguments
dDate A valid date.
Returns
nWeek The week number lIso Flag that indicates if nWeek is in ISO format.
Description
This function returns the week number of the year for a given date. It returns the week number in ISO format (range 0 - 52, by default or passing TRUE as second parameter) or 1 - 52 if lIso is FALSE.
Examples
? WoY( hb_SToD( "20000131" ) )       // --> 3
? WoY( hb_SToD( "20000131" ), .F. )  // --> 4
Status
Ready
Compliance
Harbour specific
Platforms
Available on all platforms
File
Library is hbmisc
Tag
Date
See also

TFileRead()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Read a file one line at a time
Syntax
oFile := TFileRead():New( <cFileName> [, <nReadSize> ] )
Arguments
cFileName is the required name of the file to be read.
nReadSize is the optional size to use when reading from the file. The default value is 4096 and the allowed range is 1 through 65535. Any value outside of this range causes the default value to be used.
Returns
An instance of the File Reader class
Description

TFileRead() is used to access a file one line at a time. You must specify the name of the file when an instance of the class is created.

The class data should be considered private to the class.

The class methods are as follows:

:New() Creates a new instance of the TFileRead() class.

:Open( [<nFlags>] ) Opens the file for reading. The optional nFlags

parameter can use any of the file open flags from fileio.ch. The default is FO_READ + FO_SHARED. Calling this method when the file is already open causes the next :ReadLine() to start over from the beginning of the file.

:Close() Closes the file.

:ReadLine() Returns one line from the file, stripping the

newline characters. The following sequences are treated as one newline: 1) CR CR LF; 2) CR LF; 3) LF; and 4) CR. Note: LF CR is 2 newlines.

:Name() Returns the name of the file.

:IsOpen() Returns .T. if the file is open.

:MoreToRead() Returns .T. if there are more lines to be read

(think of it as an inverse EOF function).

:Error() Returns .T. if an error has occurred.

:ErrorNo() Returns the current error code.

:ErrorMsg( [<cPre>] ) Returns a formatted error message.

Examples
LOCAL oFile := TFileRead():New( "test.txt" )
oFile:Open()
IF oFile:Error()
   ? oFile:ErrorMsg( "FileRead:" )
ELSE
   DO WHILE oFile:MoreToRead()
      ? oFile:ReadLine()
   ENDDO
   oFile:Close()
ENDIF
Status
Ready
Compliance
Not applicable
Platforms
Available on all platforms
File
Library is hbmisc
Tag
File

StrFormat()Source code โŒƒย |ย โ˜ฐย |ย Improve this doc

Format a string
Syntax
StrFormat( <cMask>[, <cPar1>[, <cParn>[, ...]] ) โ†’ cString
Arguments
cMask Holds the mask for the resulting string
cParn Holds the strings to be inserted in the mask
maximum 9 of them can be specified.
Returns
cString Return the mask with all the parameters inserted.
Description

String replacement, can be useful when writing international apps. You can separate the constant strings from the variable ones. Each %1 - %9 marks will be replaced with the appropriate parameter from the parameter list.

Marks can be in any order, and can be duplicated.

You can print % character with %%.

Examples
? StrFormat( "Please insert disk %1 to drive %2", hb_ntos( 2 ), "A:" )
? StrFormat( "This is %1 from %2", "John", "Earth" )
? StrFormat( "%2 %1 %2", "Param1", "Param2" )
Status
Ready
Compliance
Not applicable
Platforms
Available on all platforms
File
Library is hbmisc
Tag
String Tools
See also
hb_StrFormat()