StrSwap
StrTran
StrZero
SubStr
CharAdd
CharAnd
CharEven
CharHist
CharList
CharMirr
CharMix
CharNoList
CharNot
CharOdd
CharOne
CharOnly
CharOr
CharPix
CharRela
CharRelRep
CharRem
CharRepl
CharRLL
CharRLR
CharSHL
CharSHR
CharSList
CharSort
CharSub
CharSwap
CharWin
CharXOR
CountLeft
CountRight
Descend
Empty
hb_At
hb_RAt
hb_ValToStr
IsAlpha
IsDigit
IsLower
IsUpper
NumAt
NumToken
PadLeft
PadRight
POSALPHA
POSCHAR
POSDEL
POSDIFF
POSEQUAL
POSINS
POSLOWER
POSRANGE
POSREPL
POSUPPER
TokenAt
TokenEnd
TokenExit
TokenInit
TokenLower
TokenNext
TokenNum
TokenSep
TokenUpper
Convert a number from a character type to numeric
Syntax
Val( <cNumber> ) --> nNumber
Arguments
<cNumber> Any valid character string of numbers.
Returns
<nNumber> The numeric value of <cNumber>
Description
This function converts any number previously defined as an character expression <cNumber> into a numeric expression.
This functions is the oppose of the Str() function.
Examples
? Val( "31421" ) // 31421
Compliance
Clipper
Platforms
All
Files
Library is core
Seealso
Str(), Transform()
Convert a numeric expression to a character string, zero padded.
Syntax
StrZero( <nNumber>, [<nLength>], [<nDecimals>] ) --> cNumber
Arguments
<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.
Examples
? StrZero( 10, 6, 2 ) // "010.00"
? StrZero( -10, 8, 2 ) // "-0010.00"
Compliance
Clipper
Files
Library is core
Seealso
Str()
Converts any scalar type to a string.
Syntax
HB_VALTOSTR( <xValue> ) --> cString
Arguments
<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.
Examples
? HB_VALTOSTR( 4 )
? HB_VALTOSTR( "String" )
Tests
? HB_VALTOSTR( 4 ) == " 4"
? HB_VALTOSTR( 4.0 / 2 ) == " 2.00"
? HB_VALTOSTR( "String" ) == "String"
? HB_VALTOSTR( STOD( "20010101" ) ) == "01/01/01"
? HB_VALTOSTR( NIL ) == "NIL"
? HB_VALTOSTR( .F. ) == ".F."
? HB_VALTOSTR( .T. ) == ".T."
Compliance
Harbour
Files
Library is rtl
Seealso
STR()
Rounds off a numeric expression.
Syntax
ROUND( <nNumber>,<nPlace> ) --> <nResult>
Arguments
<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.
Examples
? ROUND( 632512.62541, 5 )
? ROUND( 845414111.91440, 3 )
Compliance
Clipper
Platforms
All
Files
Library is rtl
Seealso
INT(), STR(), VAL(), SET FIXED
STR()
Convert a numeric expression to a character string
------------------------------------------------------------------------------
Syntax
STR(<nNumber>, [<nLength>], [<nDecimals>]) --> cNumber
Arguments
<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.
Notes
. 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, Clipper
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.
Examples
. These examples demonstrate the range of values returned by
STR(), depending on the arguments specified:
nNumber:= 123.45
? STR(nNumber) // Result: 123.45
? STR(nNumber, 4) // Result: 123
? STR(nNumber, 2) // Result: **
? STR(nNumber * 10, 7, 2) // Result: 1234.50
? STR(nNumber * 10, 12, 4) // Result: 1234.5000
? STR(nNumber, 10, 1) // Result: 1234.5
. This example uses STR() to create an index with a compound key
of order numbers and customer names:
USE Customer NEW
INDEX ON STR(NumOrders, 9) + CustName TO CustOrd
Files Library is CLIPPER.LIB.
See Also: TRANSFORM() VAL()
FIELDSIZE()
Determines the size of a field
------------------------------------------------------------------------------
Syntax
FIELDSIZE(<nField>) --> nLength
Argument
<nField> Designates the number of the field to evaluate.
Returns
FIELDSIZE() returns a numeric value that corresponds to the field length
of a valid field number.
Description
Use FIELDSIZE() to determine the length (or size) of data field of
desired data types. This determines the window width needed for output
to appear without a line break, or the length needed for an input to
automatically fit in the database.
Note
. If there is an invalid data field number, the function returns
a value of 0.
Example
Determine the total length of fields 3 to 5:
nLength := 0
FOR I = 3 TO 5
nLength := nLength + FIELDSIZE()
NEXT
See Also: FCOUNT, FIELDNUM, FIELDNAME, FIELDTYPE, FIELDDECI, PAD, STR, DBF Structure
FIELDNUM()
Determines the field number for a specific field in a database file
------------------------------------------------------------------------------
Syntax
FIELDNUM(<cFieldName>) --> nFieldNumber
Argument
<cFieldName> Designates to the field name.
Returns
FIELDNUM() returns the number of the data field.
Description
FIELDNUM() is the exact opposite of the CA-Clipper FIELD() function.
Use this function when you need a data field number instead of the data
field name. FIELDNUM() determines if a symbol name pertains to a data
field or a memory variable (see Examples).
Note
. If a data field with the name <cFieldName> is not available,
the function returns a value of 0.
Example
Is it a field or a variable?
IF FIELDNUM("cName") > 0.
REPLACE cName WITH UPPER(cName).
ELSE.
cName := UPPER(cName).
ENDIF
See Also: FCOUNT, FIELDNAME, FIELDTYPE, FIELDSIZE, FIELDDECI, PAD, STR, DBF Structure
How I can obtain structure info of a DBF ?
PROC MAIN()
SETMODE( 25, 80 )
CLS
USE ..\datas\TEST1
? "No Field Name T Size Dec"
? "-- ------------ - ----- ---"
FOR nFld := 1 TO FCOUNT()
* or : FIELDNUM( FIELDNAME( nFld )
? STR( nFld, 2, 0 ),; // CT Database Function
PAD( FIELDNAME( nFld ), 12 ),; // Standard dBASE function
FIELDTYPE( nFld ),; // CT Database Function
STR( FIELDSIZE( nFld ), 5, 0 ),; // CT Database Function
STR( FIELDDECI( nFld ), 3, 0 ) // CT Database Function
NEXT nFld
?
WAIT "EOF DBF_Struct.prg"
RETURN // MAIN.DBF_Struct.prg"