Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this a bug?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00919603
Message ID:
00919608
Vues:
10
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
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform