WB2013 and Convert Class

Started by stanl, June 11, 2013, 05:36:12 AM

Previous topic - Next topic

stanl

Just wanted to know the caveats associated with exploring the .net Convert Class, i.e. convert to/from Base64 etc..


Deana

Quote from: stanl on June 11, 2013, 05:36:12 AM
Just wanted to know the caveats associated with exploring the .net Convert Class, i.e. convert to/from Base64 etc..

Not sure to be honest. I have never worked with that specific class. Maybe someone that has, will chime in.
Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

Quote from: Deana on June 11, 2013, 08:03:17 AM
Not sure to be honest. I have never worked with that specific class. Maybe someone that has, will chime in.
Thanks. It looks easy. The basic class has methods that convert stuff, but when I looked at some C# and PS code it seems there are bit and array variables that have to be initialized and that looked a little intimidating as you had mentioned in a previous post I made to stay away from the CLR arrays.

td

Quote from: stanl on June 11, 2013, 08:12:09 AM
...
Thanks. It looks easy. The basic class has methods that convert stuff, but when I looked at some C# and PS code it seems there are bit and array variables that have to be initialized and that looked a little intimidating as you had mentioned in a previous post I made to stay away from the CLR arrays.

Generally, WIL arrays work as [in] parameters to CLR methods or property assignments.  If you have a WIL array of numbers and the CLR method parameter is expecting something other than 4 byte intenger elements you may have to use ObjectType. For example, if an parameter is expecting an array of signed bytes you might need to do something like the following

Code (winbatch) Select

aBytes = ArrDimension(2)
aBytes[0] = 1
aBytes[1] = 2

saBytes = ObjectType("array|i1", aBytes)

before you pass the array to the method. 

The only other caveat is you cannot call methods that fill an array parameter with values.  This is because WinBatch does not support [out] parameters for CLR class methods.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl


Deana

Quote from: stanl on June 11, 2013, 11:10:20 AM
Quote from: td on June 11, 2013, 09:25:01 AM
This is because WinBatch does not support [out] parameters for CLR class methods.

So this is a no-go?
http://msdn.microsoft.com/en-us/library/system.convert.frombase64string.aspx

What makes you say that? That method doesn't have an output parameter.
Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

The Dictionary class TryGetValue Method is an example of a class method with an out parameter: http://msdn.microsoft.com/en-us/library/bb347013.aspx
Deana F.
Technical Support
Wilson WindowWare Inc.

....IFICantBYTE

Stan,
I know you love your .net and powershell stuff (fair enough), but if the end goal in this post is to convert to and from Base64, I have a couple of UDFs somewhere that I can dig up to do that if you want them? .. They call system DLLs and are fast.
If the goal is more about experimenting with the new .net/clr stuff, then no worries.. good luck.. I personally find it a bit confusing and enjoy looking at what you are dabbling with.

Regards,
....IFICantBYTE
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

stanl

Quote from: ....IFICantBYTE on June 11, 2013, 04:45:48 PM
If the goal is more about experimenting with the new .net/clr stuff, then no worries.. good luck.. I personally find it a bit confusing and enjoy looking at what you are dabbling with.


Dabbling. Yes. David Gray has an extender that does Base64 and I have an ActiveX and other WB code that can perform it. Want to update my libs to use .NET whenever possible.

stanl

Quote from: Deana on June 11, 2013, 11:19:52 AM
What makes you say that? That method doesn't have an output parameter.
It was a question and I confused output parm with output. In COM with an ActiveX I can string -> base64 string; but the .NET method appears to output an Array