viewpoint-particle

Author Topic: WB2013 and Convert Class  (Read 6757 times)

stanl

  • Pundit
  • *****
  • Posts: 934
WB2013 and Convert Class
« 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..
 
 

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: WB2013 and Convert Class
« Reply #1 on: June 11, 2013, 08:03:17 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

  • Pundit
  • *****
  • Posts: 934
Re: WB2013 and Convert Class
« Reply #2 on: June 11, 2013, 08:12:09 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

  • Tech Support
  • *****
  • Posts: 3014
    • WinBatch
Re: WB2013 and Convert Class
« Reply #3 on: June 11, 2013, 09:25:01 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
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

  • Pundit
  • *****
  • Posts: 934
Re: WB2013 and Convert Class
« Reply #4 on: June 11, 2013, 11:10:20 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

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: WB2013 and Convert Class
« Reply #5 on: June 11, 2013, 11:19:52 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

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: WB2013 and Convert Class
« Reply #6 on: June 11, 2013, 12:02:05 pm »
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

  • Full Member
  • ***
  • Posts: 120
Re: WB2013 and Convert Class
« Reply #7 on: June 11, 2013, 04:45:48 pm »
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

  • Pundit
  • *****
  • Posts: 934
Re: WB2013 and Convert Class
« Reply #8 on: June 12, 2013, 10:19:45 am »
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

  • Pundit
  • *****
  • Posts: 934
Re: WB2013 and Convert Class
« Reply #9 on: June 12, 2013, 01:09:46 pm »
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