Roberto,
>I know. It's maybe a silly question. But, I'm a newbie.
>I trying to convert a number to a localized format using this code.
>However, how you can see, it isn't working.
>What am I doing wrong?
>
>static void CCFormInit(FormPtr frmP)
>{
> CharPtr ValorFormat;
> FieldPtr fld;
>
> fld = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, CCLimCredField));
> ValFormat=(CharPtr)Registro->LimCred;
> StrLocalizeNumber((CharPtr)ValFormat, '.', ',');
> FldDrawField(fld);
>}
Your example seems a bit odd...where is the Registro variable coming
from? Why is the local variable declared as "ValorFormat", but you
use "ValFormat" in the code? Unless you pass StrLocalizeNumber a
pointer to the field's text, nothing will change when you call
FldDrawField().
Another possibility is that StrLocalizeNumber isn't doing what you
expect. All it does is (a) replace any ',' characters in the string
with what you pass in as the thousandSeparator parameter ('.' in your
example), and (b) replace any '.' characters in the string with what
you pass in as the decimalSeparator parameter (',' in your example.
So you need to first format the string to be "standard" (US -
thousands separator is a comma, decimal separator is a period), and
then call StrLocalizeNumber. Since you're hard-coding the separators,
you could skip the call to StrLocalizeNumber.
-- Ken
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200