Hi Eszter,
Your PB app converts to/from string based on end-user's regional settings at runtime!
AND - while your app runs - user changes regional settings - Bazinga! - Your app may read "123.45" as 123.45 one moment and as 12345 the next moment.
AND - your DB server or DB connection may use different settings.
So you should avoid depending on string conversion. Less code. Faster performance.
Alternative, write conversion utility that checks at runtime and handles character replacement as part of conversion function.
UPDATE
I wrote a short test app to demo numeric conversion for Byte/Int/Long/LongLong/Decimal/Real/Short and tested various combinations of decimal marker and group marker. I tested for en-US, da-DK, and hu-HU since they use different decimal/grouping markers. These are my results:
Read test results as follows:
Test Result |
IsNumber(...) returns |
Converted Number |
OK |
TRUE |
Correct |
FAIL |
FALSE |
0 (value not understood) |
WARNING |
TRUE |
WRONG! (value misunderstood) |
Convert FROM string - decimal point - comma grouping - EX: en-US
- OK
- Pure digits
- Digits + 1 decimal point
- Decimal point BEFORE first digit (.789 == 0.789)
- Any comma BEFORE decimal point (commas ignored)
- WARNING
- Comma instead of decimal point (ignored as group marker)
- 123,45 == (comma ignored) == 12345
- FAIL
- Any comma AFTER decimal point (1.23,45 == 0)
- Any comma BEFORE/AFTER numeric value (,789 == 0)
- Space ANYWHERE in numeric value (123 45 == 0)
Convert FROM string - decimal comma - point grouping - EX: da-DK
- OK
- Pure digits
- Digits + 1 decimal comma
- Decimal comma BEFORE first digit (,789 == 0,789)
- Any point BEFORE decimal comma (points ignored)
- WARNING
- Point instead of decimal comma (ignored as group marker)
- 123.45 == (point ignored) == 12345
- FAIL
- Any point AFTER decimal comma (1,23.45 == 0)
- Any point BEFORE/AFTER numeric value (.789 == 0)
- Space ANYWHERE in numeric value (123 45 == 0)
Convert FROM string - decimal comma - space grouping - EX: hu-HU
- OK
- Pure digits
- Digits + 1 decimal comma
- Decimal comma BEFORE first digit (,789 == 0,789)
- FAIL
- Space ANYWHERE in numeric value (despite space being group marker)
- Comma ANWHERE in numeric value (neither decimal nor group marker)
CONCLUSION ::
A: Mix-up of decimal marker and group marker either ruins the value (IsNumber = false and converted to zero) or results in misunderstood value (IsNumber = TRUE DESPITE converted to wrong value).
B: PowerBuilder conversion FROM strings can't handle values where SPACE character is group marker.
HTH /Michael