Board index » delphi » Change Decimal separator for ALL controls...

Change Decimal separator for ALL controls...

Hi,

My Window's version control panel DecimalSeparator character is a comma (,).

In my app I need to alter the Decimal separator value according to the
currency selected by the user.  I thought that it was sufficient to set
SysUtils.DecimalSeparator := '.' but this unfortunately does NOT affect the
TFields.IsValidChar method.

When Sysutils.Decimalseparator is anything else than a comma (control
panel's value) MyTable.Field.IsValidChar(SysUtils.Decimalseparator)) returns
FALSE!

For all other controls, captions and displays it works just fine and follows
the assigned character to Sysutils.Decimalseparator.

Any clue why I the TField.IsValidChar 'character set' isn't updated to
reflect the Decimalseparator change?  OR how can I update it??

Thanks a lot for any tip on this..

regards

Tor

 

Re:Change Decimal separator for ALL controls...


Tor,

<< My Window's version control panel DecimalSeparator character is a comma
(,).
In my app I need to alter the Decimal separator value according to the
currency selected by the user.  I thought that it was sufficient to set
SysUtils.DecimalSeparator := '.' but this unfortunately does NOT affect the
TFields.IsValidChar method. >>

The IsValidChar method for TBCDFields and TFloatFields does *indeed* look at
the DecimalSeparator global variable.

<< When Sysutils.Decimalseparator is anything else than a comma (control
panel's value) MyTable.Field.IsValidChar(SysUtils.Decimalseparator)) returns
FALSE! >>

This can't be - essentially this would result in:

  Result :=  DecimalSeparator in [DecimalSeparator, '+', '-', '0'..'9', 'E',
'e']; { Float field }
  Result :=  DecimalSeparator in [DecimalSeparator, '+', '-', '0'..'9'];
 BCD Field }

Obviously this should work.

<< For all other controls, captions and displays it works just fine and
follows the assigned character to Sysutils.Decimalseparator.  Any clue why I
the Field.IsValidChar 'character set' isn't updated to reflect the
Decimalseparator change?  OR how can I update it?? >>

Something else is going on here.  The IsValidChar checking does take into
account the DecimalSeparator character.

If you'd like to see this type of thing working in action we do it with the
latest version of our DBISAM Database System Utility (you can download it at
www.elevatesoft.com/downloads/dbisamtr.zip .  We set display formats and
edit masks based on the active data file's international settings and
independent of the Control Panel settings. Basically it involves switching
around the format variables such as the DecimalSeparator character.

I hope that helps,

Tim Young
Elevate Software
www.elevatesoft.com

Re:Change Decimal separator for ALL controls...


Tor,
  the DecimalSeperator is used to initialize the ValidChars for
TFloatFields when the TFloatField is first created.  Therefore, if you set
the SysUtils.DecimalSeperator to something other than the system settings,
you will not see this change in any field which was created before you set
the value.  If you are creating your tables at run time, you can set this
value before creating any tables.  If you are using design-time created
tables, you will probably have to go into your project source code and make
the change before any of your forms are created.  You can also change
ValidChars yourself, I believe, since it is a public property of the
TField.
-Howard Moon

Re:Change Decimal separator for ALL controls...


Quote
Tim Young wrote in message <712frg$7...@forums.borland.com>...

Thanks a lot for your info, Tim.  You say what I expected to happen ;-|

Quote
>This can't be - essentially this would result in:

>  Result :=  DecimalSeparator in [DecimalSeparator, '+', '-', '0'..'9',
'E',
>'e']; { Float field }
>  Result :=  DecimalSeparator in [DecimalSeparator, '+', '-', '0'..'9'];
> BCD Field }

>Obviously this should work.

Well - I skipped my de{*word*81} and wrote this:

 SysUtils.Decimalseparator := ','; // Comma
  if
Accounting.tblCurrency.FieldByName('Rate').IsValidChar(SysUtils.Decimalsepar
ator)
    then ShowMessage('TRUE')
    else ShowMessage('FALSE');

This returned TRUE

Then I changed the Decimalseparator to a dot:

 SysUtils.Decimalseparator := '.'; // Dot
  if
Accounting.tblCurrency.FieldByName('Rate').IsValidChar(SysUtils.Decimalsepar
ator)
    then ShowMessage('TRUE')
    else ShowMessage('FALSE');

This returns FALSE - which is the problem I'm trying to explain!

I'm using Delphi 3.02 C/S and FlashFiler tables (but the TFields are the
VCL's)

I see yuor consequently refers to Decimalseparator, and I assume you mean
Sysutils.Decimalseparator....

Is it a single byte-bug in my Delphi...?

Regards

Tor

Re:Change Decimal separator for ALL controls...


Quote
Howard Moon wrote in message <01be0112$2abe0d50$7b19cbaa@jax-97-0410>...
>Tor,
>  the DecimalSeperator is used to initialize the ValidChars for
>TFloatFields when the TFloatField is first created.  Therefore, if you set
>the SysUtils.DecimalSeperator to something other than the system settings,
>you will not see this change in any field which was created before you set
>the value.  If you are creating your tables at run time, you can set this
>value before creating any tables.  If you are using design-time created
>tables, you will probably have to go into your project source code and make
>the change before any of your forms are created.  You can also change
>ValidChars yourself, I believe, since it is a public property of the
>TField.
>-Howard Moon

Howard,

GREAT! thanks for clarifying this.  This explains everything...

I'll update the set manually when I change the decimalseparator property.

Best regards

Tor

Other Threads