Monday, March 31, 2008

Ruby, ruby, ruby ...

Yeah it's been a while since the last posting. I was lacking some inspiration on what to blog on or I was just too lazy or too busy to actually log in and blog on something that I wanted to, that is until now...

You might ask, whats up with the title? Well I remember the song written by a band called Keizer Chiefs (spelling) named: Ruby. Now that reminds me of the Ruby scripting language which lots of people on the web is going on about. A dynamic typed language with multiple ways of saying one thing.

I was among those who agreed that Ruby was stupid, until I wanted to do a few things in Windows which Python nor other scripting languages could offer (or easily accomplish), except Ruby. Some of us would mock the guy who presented a brief crash course in Ruby, saying that it is too dynamic for our taste and it would make debugging a nightmare, etc. but doing some code delving and with the latest Netbeans language addition, which is Ruby and Ruby on Rails of course, I started to see how cool Ruby actually is.
Usually I despised dynamic typed languages until I saw how it can increase productivity and coding speed for smallish scripts, which is what I wanted for automation.

"What kind of automation?" you may ask. Well ordinary and OLE automation. Sure AutoIT is great for GUI and other windows automation but the scripting language is very BASIC (pun intended) lacking structure and (as in, I need structures as in C or C++'s structures or atleast...) object orientation. With Ruby we have good OO support and with the 'win32ole' lib, you can kick VBA and do MS Office automation via Ruby instead. A good starting site is Ruby on Windows which covers Ruby automation in MS Office. I managed to convert Powerpoint slides to somewhat formatted Word docs via Ruby, just to give you an idea.

I think I'll post a couple of script snippets later on, on what I worked on with Ruby and AutoIT for others to see and for future reference.

Just to go back to Python, some of you might say that Python does have OLE automation... I had a look at it and it looked very nasty! I wouldn't touch it, unless I looked at the wrong files, and you need to download a library for Python to have OLE automation ability. With Ruby you use the OLE objects exactly as in VBA but within your Ruby context.

Currently I am trying to implement a few operations in Ruby to have Browse-For-Folder ability, Open-Dialog, and so on functionality by doing Windows API calls via the DL lib in Ruby. You can catch a quick course on DL here.

I hope this will help you as much as it helped me.
God Bless!

1 comment:

David Mullet said...

Thanks, LA, for recommending my Ruby on Windows blog!

God Bless.