Sergey,
thanks! I always get great answers from you!
I did implemented it into a function because the string may be null.
Regards,
Ron Brahma
>Hi Ron,
>
>You can do that w/o finction.
? TRANSFORM(PADL(cNumber,16), "@R X XXX XXX XXX XXX XXX")
>
>>I have been having problems with a function where I want to display for instance the following number 1234567 as 1 234 567. I want to do this to make a report more readable.
>>
>>I came up with the following function:
>>
>>PROCEDURE formatNumber(cNumber as String)
>>cSeperator = ' '
>>cNumber = PADL(ALLTRIM(cNumber), 16, cSeperator )
>>
>>cString = ;
>> cSeperator + SUBSTR(cNumber,01,1) +;
>> cSeperator + SUBSTR(cNumber,02,3) +;
>> cSeperator + SUBSTR(cNumber,05,3) +;
>> cSeperator + SUBSTR(cNumber,08,3) +;
>> cSeperator + SUBSTR(cNumber,11,3) +;
>> cSeperator + SUBSTR(cNumber,14,3)
>>RETURN (cString)
>>
>>If I try the following code:
>>?formatNumber('100000')
>>the function returns an empty code. When testing this in the debugger I function called is telling me that an empty string was passed into the function.
>>
>>If I now change the function to:
>>PROCEDURE formatNumber(cWhatEver as String)
>>cSeperator = ' '
>>cNumber = PADL(ALLTRIM(cWhatEver ), 16, cSeperator )
>>
>>cString = ;
>> cSeperator + SUBSTR(cWhatEver ,01,1) +;
>> cSeperator + SUBSTR(cWhatEver ,02,3) +;
>> cSeperator + SUBSTR(cWhatEver ,05,3) +;
>> cSeperator + SUBSTR(cWhatEver ,08,3) +;
>> cSeperator + SUBSTR(cWhatEver ,11,3) +;
>> cSeperator + SUBSTR(cWhatEver ,14,3)
>>RETURN (cString)
>>
>>and try again the '100000' is properly passed into the function.
>>Why is this? Is the cNumber reserved for other uses?
>>
>>I'm doing this with VFP7.
>>
>>Regards,
>>Ron