Forum Discussion

Morgan's avatar
Morgan
Frequent Contributor
15 years ago

Regionalization & Localization compatability

In Delphi, can you think of a way to set the decimal separator from '.' to ',' programmatically for any defined value throughout the script?  Is there a way to call a line or two of code that will change it?  For example, a line of code might have something like the following in a North American region...



Sys.Keys('0[Enter]3.6[Enter]7.3[Enter]13.0[Enter]20.0[Enter]'); 



But!  When I change to a European region, what I want to use as input is commas instead of periods in place of decimals.  



Any way to easily do this at the beginning of the script or am I stuck because it's using Sys.Keys?



Thanks,

Morgan 

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You're stuck for two reasons.



    First of all, you're using "Keys" which is going to send the literal string to the screen so there's not a way of telling the Keys method "replace period with comma".



    Second stuck is that you're using hardcoded strings period.  Even if you were using SetText('3.7') or simply Object.Text := '3.7' you'd still have a problem because, again, it's a literal string being sent.



    Now, if you were doing a data driven test of sorts where you're reading values in from a file, you could simply have different files for different regional settings...



    .. OR... go one step further and write custom code to read the values from the file, translate them into regionalized values, and then pass them in to Keys, SetText or whatever other function you need.
  • Morgan's avatar
    Morgan
    Frequent Contributor
    I thought so.  I'm with you on the DDT (I inherited these scripts).  I'll modify it to work for what we need it to do.



    Thanks!

    Morgan