WinBatch Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on February 17, 2019, 05:33:13 am

Title: More fun with CLR
Post by: stanl on February 17, 2019, 05:33:13 am
The code below is not earth-shattering but it is interesting to see how easily WB and the CLR can get-along. This is not to underestimate the power of WB to do most anything, but I am looking at building a couple of UDF's that return specific .NET types, conversions, or processes related to encoding and culture. Also a good way to refresh with how classes can be addressed in .NET

Code: Winbatch

;Winbatch 2018B - CLR method to convert Date to DTMF
oM = ObjectClrNew( "System.Management.ManagementDateTimeConverter")
d=TimeFormat(d,"MM/dd/yyyy hh:mm:ss t")

Message("Convert Date To DTMF",d:@LF:wmi)

Title: Re: More fun with CLR
Post by: stanl on February 17, 2019, 11:08:55 am
which brings up this point...

this code
Code: Winbatch

oCal = ObjectClrNew("System.Globalization.Calendar")
oCulture = ObjectClrNew("System.Globalization.CultureInfo")

;TFormat = oCulture.CurrentUICulture

fails for CultureInfo [I put Calendar in just to show a class that didn't error.... ] Trying to get to CultureInfor in WB was meant to replicate the PS one liner


NOT a WB issue, just more a learning curve... so modify to

oCulture = ObjectClrNew("System.Globalization.CultureInfo","es-ES")

and Voila!