hb_C - Petewg/harbour-core GitHub Wiki
-
hb_CDay(
<nDay>
) ➜ cDayName
returns the name of day specified by<nDay>
. Valid range [ 1 ... 7 ]. Returns empty string if<nDay>
is out of valid range. RTE occurs if<nDay>
is NIL (i.e. not passed).
Worth noting that the returned value is identical to that ofCDoW()
but the later accepts a date value as parameter. -
hb_cdpCharMax(
[<cCPID>]
) ➜ nChars
returns the total characters included in current or given<cCPID>
code-page character table. Basically,65535
for Unicode or255
for non-Unicode code-pages. -
hb_cdpExists(
<cCPID>
) ➜ lExists
returns .T. if given<cCPID>
exists, otherwise .F.. -
hb_cdpInfo(
[<cCPID>]
) ➜ cInfo
returns a short description about the current or the given<cCPID>
code-page. -
hb_cdpIsCharIdx(
[<cCdpID>] [,<lNewMode>]
) ➜ lPrevMode
It returns .T. when given code-page uses custom character indexes instead of byte indexes. If<cCdpID>
is not specified then currentHVM
code-page is used. Optional logical parameter<lNewMode>
allows to enable/disable custom character indexes in code-pages which have such functionality, i.e. UTF8, BIG5, CP950. -
hb_cdpIsUTF8(
[<cCPID>]
) ➜ .T.|.F.
returns .T. if the current or the given<cCPID>
code page is UTF8 otherwise returns .F. -
hb_cdpList() ➜ aCodePages
returns an array with code-pages registered (linked) in application (via arequest <hb_codepage_xxxxx>
statement).
Note: in order to get a complete list with all code-pages supported by harbour, the"hbextcdp.ch"
must be #include(d) in module that is invoking this function. -
hb_cdpOS() ➜ cCPID
returns O/S code-page ID. -
hb_cdpSelect(
[<cNewCPID>]
) ➜<cPrevCDP>
Set/get current code-page being used by application.
<cNewCPID>
(must be in uppercase!) is an optional code-page ID to become current.
Important: before invoking the function (for set), you must, previously, REQUEST the linkage of proper code-page object you intend to use; this can be done using the statement:
REQUEST HB_CODEPAGE_ITWIN
(for italian "win" code page.)
The function returns the previous (old) code-page.
NOTE: The hb_cdpSelect() function has the same functionality as Set(_SET_CODEPAGE) function (cited below for convenience).-
SET(
_SET_CODEPAGE, [<cCDP>]
) ➜<cPrevCDP>
set/get internal HVM codepage which is used in string comparison operation functions likeUPPER()/LOWER()/ISALPHA()/ISUPPER()/ISLOWER()/ISDIGIT()/...
and also as default CP for RDD when new table is open and for GT in HB_SETTERMCP()/HB_SETDISPCP()/HB_SETKEYCP(). Some GTs also use it even without calling above functions.
See also, an interesting post in harbour-users group regarding code-pages.
Below is code to define/use a new code-page, derived from the very same post:REQUEST HB_CODEPAGE_ENWIN PROCEDURE Main() Set( _SET_CODEPAGE, "ENWIN" ) ? Set( _SET_CODEPAGE ), hb_cdpUniID( Set( _SET_CODEPAGE ) ) ? "Abschöpfung.jpg:", file( "Abschöpfung.jpg" ) RETURN #pragma begindump #define HB_CP_ID ENWIN #define HB_CP_INFO "English CP-1252" #define HB_CP_UNITB HB_UNITB_1252 #define HB_CP_ACSORT HB_CDP_ACSORT_NONE #define HB_CP_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define HB_CP_LOWER "abcdefghijklmnopqrstuvwxyz" #define HB_CP_UTF8 #include "hbcdpreg.h" /* include CP registration code */ #pragma enddump
-
SET(
-
hb_cdpTerm() ➜ cCPID
returns terminal's code-page ID. -
hb_cdpUniID(
[<cCPID>]
) ➜ cID
returns code-page identifier in the formcp<NNN[N]>
, that is, the code-page number prefixed bycp
. -
hb_Clocks2Secs(
<nClocks>
) ➜ nSecs
returns CPU clocks converted to seconds. -
hb_CmdLine() ➜ cString
returns the full command line, i.e.: all command line arguments (parameters). -
hb_ColorIndex(
<cColorString>, <nColorIndex>
) ➜ cColorPair or NIL
returns the given<nColorIndex>
color pair (foreground/background) from<cColorString>
list of color attributes
in the format ofSETCOLOR("...")
parameter, or NIL in case of invalid parameters.Constants for
<nColorIndex>
are defined into Color.ch as follow:Constant Value CLR_STANDARD 0 CLR_ENHANCED 1 CLR_BORDER 2 CLR_BACKGROUND 3 CLR_UNSELECTED 4 -
hb_compile(
"harbour", <cFileName>, [<cSwitches>...]
) ➜ nRetCode
compiles the filecFileName
with compiler switches passed. The result of compilation is a.c
file. -
hb_compileBuf(
"harbour", <cFileName>, [<cSwitches>...]
) ➜ cP-Code
compiles<cFileName>
into pre-compiled harbour binary (p-code) and returns it, to be used by hb_hrb*** functions and can be saved as.hrb
file. -
hb_compileFromBuf(
<cHrbCode>, "harbour", [<cSwitches>...]
) ➜ cP-Code
compiles<cHrbCode>
into pre-compiled harbour binary (p-code) and returns it, to be used by hb_hrb*** functions and be can saved as.hrb
file. Parameter<cHrbCode>
must be a string buffer of plain harbour code.
[Note: there is a small typo (hard-coded) inside hbmk2.prg where the name of this function is referred with an extra 'f' at the end, so when you usehbmk2 -find hb_compileFrom
you'll misleadingly gethb_compileFromBuff
which shall produce an 'undefined reference' error during compile.] -
hb_Compiler() ➜ cCCompiler
returns theC
compiler, f.e.MinGW GNU C 5.3 (32-bit)
, used to build Harbour executable binaries. -
hb_CRC(
<cValue> [, <nStart> ] [, <nPolynomial>]
) ➜ nCRC8
returns the checksum of a string using theCRC-8
algorithm. -
hb_CRC16(
<cValue> [, <nStart> ]
) ➜ nCRC16
returns the checksum of a string using theCRC-16
algorithm. -
hb_CRC32(
<cValue> [, <nStart> ]
) ➜ nCRC32
returns the checksum of a string using theCRC-32
algorithm. -
hb_CRCCT(
<cValue> [, <nStart> ] [, <nPolynomial>
) ➜ nCRCCT
returns the checksum of a string using CRC-8?, cl*pper tools compatible? or what? (clarification needed...). Anyhow, Przemek suggests to not use it. -
hb_CStr(
xVal
) ➜ cExp
Converts a value of any type into a string expression. Complex types are converted into a descriptive text.
See also:hb_ValtoExp()
,hb_ValToStr()
-
hb_CtoD(
<cDate> [, <cDateFormat>]
) ➜ dDate
Harbour extension to the CtoD() function. It converts a string<cDate>
representing a date to a DATE type value. Additionally, the date format used in<cDate>
can be supplied in<cDateFormat>
, otherwise the_SET_DATEFORMAT
format will be used. -
hb_CtoT(
<cTimeStamp> [, <cDateFormat>, <cTimeFormat>]
) ➜ tTimeStamp
converts a timestamp string to timestamp value (valtype=T). By default it uses the_SET_DATEFORMAT
and_SET_TIMEFORMAT
format strings to do the conversion, but you can specify other formats using<cDateFormat>
and<cTimeFormat>
. -
hb_CurDrive(
[<cNewDrive>]
) ➜ cCurrentDrive
returns the current working disk drive as a single capital letter (e.g.C
) and optionally changes it to<cNewDrive>
.
-
hb_cwd(
[<cNewDir>]
) ➜ cCurrentDir|PrevDir
Get/Set the Current Working Directory.
If a<cNewDir>
argument has been passed, the function attempts to set it as (current) working directory. Whether the new working directory setting was successful or not, can be checked either by using FError():cOldPath := hb_cwd( cNewPath ) IF FError() != 0 ? "Cannot set working directory to " + cNewPath ELSE ? "Working directory changed from " + cOldPath + " to " + cNewPath ENDIF
or by using hb_cwd() itself: 😉
cOldPath := hb_cwd( cNewPath ) IF cOldPath == hb_cwd() // directory didn't change! ? "Cannot set working directory to " + cNewPath ELSE ? "Working directory changed from " + cOldPath + " to " + cNewPath ENDIF
The function always returns the full path of directory that is current upon invocation, (i.e. the path before the possible change is made, when a change is aimed), including drive letter (if the O/S supports that) and a trailing slash (or back-slash).