x# transform() and SetCentury() issues

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

x# transform() and SetCentury() issues

Post by Karl-Heinz »

Guys,

1. I´ve noticed that transform() adds unnecessary thousands separators

Code: Select all


?
? "SetThousandsep() " + chr (  SetThousandsep () ) // "."  ok
? "SetDecimalsep() " + chr (  SetDecimalsep () )   // ","  ok

? transform (    2.45 ,   "@R 999,999.99" )	// "   .  2,45" 
? transform (   -2.45 ,   "@R 999,999.99" )     // "   . -2,45"
? transform (   24.58 ,   "@R 999,999.99" )	// "   . 24,58" 
? transform (  -24.58 ,   "@R 999,999.99" )     // "   .-24,58"  	
? transform (  245.78 ,   "@R 999,999.99" )	// "   .245,78" 
? transform ( -245.78 ,   "@R 999,999.99" )	// "  -.245,78"  <----
? transform ( 1245.78 ,   "@R 999,999.99" )     // "  1.245,78"     ok
? transform (-1245.78 ,   "@R 999,999.99" )     // " -1.245,78"     ok 
? transform ( 1245.78 ,   "@R 999,999,999.99" ) // "   .  1.245,78"
? transform (-1245.78 ,   "@R 999,999,999.99" ) // "   . -1.245,78"
? transform ( 245.78 ,    "@R 999,999,999.99" )	// "   .   .245,78"
? transform ( 551245.78 , "@R 999,999,999.99" ) // "   .551.245,78"  

// without thousand sep
? transform (   24.58  , "@R 999999.99" )    // "    24,58"   ok
? transform (  -24.58  , "@R 999999.99" )    // "   -24,58"   ok
? transform ( -234.45  , "@R 999999.99" )    // "  -234,45"   ok 
? transform ( 234.45   , "@R 999999.99" )    // "   234,45"   ok
? transform ( -1234.45 , "@R 999999.99" )    // " -1234,45"   ok 
? transform ( 1234.45  , "@R 999999.99" )    // "  1234,45"   ok
?

// problem with none floats

? transform ( -124 , "@R 999,999.99" )   // "   .  -,24"   
? transform ( 124 , "@R 999,999.99" )    // "   .   ,24" 
   
// without thousand sep
? transform ( -124 , "@R 999999.99" )    // "     -,24"   
? transform ( 124  , "@R 999999.99" )    // "      ,24"
? transform ( -124 , "999999.99" )       // "     -,24"   
? transform ( 124  , "999999.99" )       // "      ,24"  



2. SetCentury() does not alter the year part of the date template.


Note: a german windows is used.

Code: Select all

LOCAL d AS DATE

d := condate ( 2018 , 8 , 12 ) 
 	                          	

// The default Setcentury() setting is false - VOs default is true
? Setcentury()    // false
// but the 4 digits year format is active
? GetDateFormat() // DD.MM.YYYY
? d               // 12.08.2018
?

SetCentury( FALSE )
// Setcentury() doesn´t change the date template. 
// the 4 digits year format is still active. 
? SetCentury()
? GetDateFormat() // DD.MM.YYYY
? d               // 12.08.2018  
? 
SetCentury(TRUE)
?
// force a 2 digits year display
// note: SetDateFormat() changes the SetCentury() setting automatically
SetDateFormat ( "DD.MM.YY" )
? Setcentury()  // ok, shows false now      
? GetDateFormat() // ok DD.MM.YY
? d               // ok 12.08.18
?
// force a 4 digits year display
// note: SetDateFormat() changes the SetCentury() setting automatically   
SetDateFormat ( "DD.MM.YYYY" )
? Setcentury()       // ok, shows true now       
? GetDateFormat() // ok DD.MM.YYYY
? d               // ok 12.08.2018 
?



SetCentury() should change the date template automatically, similar as SetDateFormat() automatically changes the SetCentury() setting.


regards
Karl-Heinz
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

x# transform() and SetCentury() issues // misuse for enhancement plea

Post by FFF »

Sorry for OT: could we have an extension to the "?" which automatically adds the expression to the output? E.g:
? DoW()
Resulting in:
Sunday // DoW()
Or similar.

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

x# transform() and SetCentury() issues

Post by robert »

Karl Heinz,
Thanks for the examples. We will try to fix this for the next build.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

x# transform() and SetCentury() issues

Post by Karl-Heinz »

Hi Robert,

At first glance it´s a little bit confusing that SetInternational () and SetCollation () process the same params.
"clipper", "Windows", "unicode" or "ordinal". But in the meantime it´s clear how Setinternational() handles "unicode" and "ordinal".

SetInternational ( #unicode )
? SetInternational() // falls back to "windows"

SetInternational ( #ordinal )
? SetInternational() // falls back to "windows"

I´ve noticed that SetInternational() no longer adjusts the collation setting automatically . Maybe i overlook something, but why not set the collation automatically according the SetInternational() param ?

e.g.

SetInternational ( #unicode )

would result in:

SetInternational() == Windows
SetCollation() == unicode


regards
Karl-Heinz
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

x# transform() and SetCentury() issues

Post by robert »

Karl Heinz,

I am working on documentation for this.
Short version: SetInternational only #Windows and #Clipper
This controls how date format time format and decimal and thousand seperators are defined.

SetCollation #Windows, #Clipprt, #Unicode and #Ordinal. This determines the sort order and string comparisons.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply