RSSThe TSW Blog

The making of "WebCoder.NET" – part 3

January 15, 2007

One of the big questions I was facing when I started working on "WebCoder.NET", was the integrated scripting which has been a part of WebCoder for the last couple of versions. When switching from Delphi to .NET, I had to find replacements for the part of the applications which I can't or won't make my self. In the Delphi world, this is referred to as "3rd party components" or simply "Components". These components are like building blocks, allowing you to use the work of other people in certain places. For instance, creating a fully featured component for editing and syntax highlighting code would probably take a single person many months of really hard work. As you can see in WebPad.NET, I have found really good replacements for the components used in the Delphi version of WebCoder, but for the next version, I really needed a good component for handling scripting.

I searched a lot, but no real good alternatives turned up, and at one point, I was actually considering to skip the scripting support, partly because I wasn't sure how many people were actually using it. Fortunately, I finally found a solution that seems to be just right for WebCoder. IronPython is an implementation of Python for .NET, created by Microsoft actually. I didn't know anything about Python, but a couple of nerdy friends seemed to be very fond of it, so I gave it a try. It turned out to be a very nice implementation, allowing the scripter to interact with the entire .NET framework, and Python is actually a pretty nice language to work in. It's not that different from the scripting used in the current version of WebCoder, and people with experience from other programming languages will probably find it easy to use.

As I described earlier, one of my main concerns about missing a scripting engine, was the tag dialogs. As you may know, all the HTML tag dialogs of WebCoder 5 and 2005 is based on XML and scripting, instead of the usual approach of building them as a part of the application. This allows the user to change the existing dialogs and even create new ones. With the new scripting engine in place, it was really just about rewriting all the dialogs to use the new scripting language. I'm almost done, and so far everything has turned out pretty well. Looking at my old XML code, I decided to freshen it up a bit, to make it more readable, so I wrote a nice little utility to convert and change where I found it appropriate. Hopefully we will see more user created dialogs with next version of WebCoder :)

I will end this post with a small example of the scripting in "WebCoder.NET", to show you how easy it is. These few lines of code will replace < and > characters in the current document with their HTML entities:

code = Editor.Text
 
code = code.Replace("<", "&lt;")
code = code.Replace(">", "&gt;") 

Editor.Text = code
Kasper (TSW) @ 10:37 am in WebCoder

Leave a Reply