Convert a numeric expression to a character string

     STR(<nNumber>, [<nLength>], [<nDecimals>]) --> cNumber


     <nNumber> is the numeric expression to be converted to a character

     <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.


     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


     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


     .  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.


     .  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.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.