DOCUMENT:Q88985 23-OCT-1999 [foxmisc] TITLE :Converting a Numeric Value to a String PRODUCT :Microsoft Fox Miscellaneous Products PROD/VER:MS-DOS:1.21,2.1 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft FoxBASE+ for MS-DOS, versions 1.21, 2.1 ------------------------------------------------------------------------------- SUMMARY ======= When FoxBASE+ converts a numeric value to a string, the numeric is automatically left padded to a length of 10 characters. For example, if a program contains the following code x = 455 ? STR(x), LTRIM(STR(x)) it returns the following values: " 455", "455". To string numeric values with decimals, include the length of the entire number and the number of decimal places desired to display. The following are examples of using the STR() function with numbers that include decimals: x = 234.98 ? STR(x,10,2), LTRIM(STR(x,10,2)) The program returns the following values: " 234.98","234.98". When doing string comparisons, it is important to make sure the values being compared are in the same format. If the above values are compared, they will not be equal. For example: x=12 ? STR(x)=LTRIM(STR(x)) && returns .F. MORE INFORMATION ================ STR([,[,]]) - Changes a numeric value to a string - Numeric expression to convert to a character - Length of the string to return (optional) - Number of decimal places to use (optional) LTRIM() - Removes all spaces from the left side of a string - Character expression Additional query words: ====================================================================== Keywords : Technology : kbAudDeveloper kbFoxproSearch kbFoxBASE210DOS kbFoxBASE121DOS kbFoxBASESearch Version : MS-DOS:1.21,2.1 ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1999.