Harbour All Functions – S

SaveToken

SayScreen

Seconds
Secs

Select

Set

SetAtLike

SetDate

SetKey

SetMode

SetPrec

SetTime

SetTypeahead

Sign

Sin

SinH

Space

Sqrt

Str

StrDiff

StrFormat

StrSwap
StrTran
StrZero
SubStr

Harbour String Functions

AddASCII

AfterAtNum

AllTrim
Asc

ASCIISum

ASCPos
At

AtAdjust

AtNum
AtRepl
AtToken

BeforAtNum

Chr

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

JustLeft
JustRight

Left
Len
Lower
LTrim

NumAt
NumToken
PadLeft
PadRight

PadC
PadL
PadR

POSALPHA
POSCHAR
POSDEL
POSDIFF
POSEQUAL
POSINS
POSLOWER
POSRANGE
POSREPL
POSUPPER

RangeRem
RangeRepl

RAt

RemAll

RemLeft
RemRight
ReplAll

Replicate

ReplLeft

ReplRight

RestToken

Right
RTrim

SaveToken

SetAtLike
Space
Str

StrDiff

StrFormat

StrSwap

StrTran
StrZero
SubStr

TabExpand
TabPack

Token

TokenAt
TokenEnd
TokenExit
TokenInit
TokenLower
TokenNext
TokenNum
TokenSep
TokenUpper

Transform
Trim
Upper
Val

ValPos
WordOne
WordOnly
WordRem
WordRepl
WordSwap

WordToChar


Val()

Val()

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()

StrZero()

StrZero()

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()

hb_ValToStr()

HB_VALTOSTR()

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()

Round()

ROUND()

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

C5_STR

 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()