Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / C++

Include Scripting Engine in Your Own Application

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
4 Aug 2011Apache2 min read 14.3K   5   1
How to include a scripting engine in your own application

Have you ever thought about including a scripting engine into your application? Maybe for advanced users, or just to be able to automate some things?

Goals of a Scripting Language

So what do you expect from an scripting engine?

First of all, you want it to be simple but it should also be powerful. Experienced users should get the chance of performing advanced tasks.

Most builtin scripting languages also provide their own command set, e.g. Read/Write application configuration without parsing any file.

As we are developing in the .NET world, all this cries for using a CLR Language as scripting language, but there remains one problem.

How to Achieve Simplicity

Imagine someone just wants to output some lines to the console:

C#
public class Test
{
  static void main(string[] args)
  {
    Console.WriteLine("myText");
  }
}

That's definitely not what I would call simple!

What Do We Need to Make this Simpler?

My idea of solving this situation works as follows:

  1. Eliminate the need to write class and method definitions

    Just write:

    C#
    Console.WriteLine("myText");

    This will be automatically embedded into a class and method definition.

  2. Provide the possibility to include user written methods and classes

    For simple tasks, the overhead is minimized and more advanced users can still show what they can. ;-)

  3. Provide the possibility to register custom methods and properties

    They are directly usable from the user script. See TestEnvironment of DevEck.ScriptingEngine.

Check Out the Scripting Engine and Example Application

I implemented the mentioned things and attached the library with a simple test projects. The test project accepts VB.NET code, but you can switch to C#. I currently use it in a highly database enabled application for automating SQL Queries.

If you like it, please leave me a comment.

Update 14.01.2010

  • I moved the source to github, browse to http://github.com/deveck to see my other projects.
  • To clone the source, do the following:

    Code:

    git clone git://github.com/deveck/dotNet_ScriptingEngine.git
  • If you are not familiar with git, have a look at http://help.github.com/.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Student
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionTest project Pin
Terence Wallace5-Jan-18 15:04
Terence Wallace5-Jan-18 15:04 
Any sample in depth test projects available?
"If you feel the urge to add complexity, just go home early. You ain't gonna need it." - YAGNI

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.