Archive

Archive for December, 2010

rScript 1.2 released

December 12, 2010 Leave a comment

It’s been less than a week and I’ve already released a 2nd update to the rScript Engine. Version 1.2 includes a couple nice features that required quiet a bit of re-coding in order to get them built in, but it went together smoothly and I think the changes make the engine a much better solution than it was in version 1.1.

So what changed? For starters, the ScriptRepository property was removed and the Compile() method gained three variations to itself. You can now compile a directory full of scripts, a single file or raw source code.

Here is an example of compiling a complete directory.

static void CompileScriptRepository()
        {
            //The directory that contains a collection of scripts.
            String scriptRepository = "Scripts";

            //Compile all scripts within that directory.
            Boolean isCompiled = _CompileEngine.Compile(scriptRepository);

            //Check for any compiler errors.
            if (!isCompiled)
            {
                Console.WriteLine(_CompileEngine.Errors);
            }
        }

And another example, this time showing how to compile a single file.

static void CompileScriptFile()
       {
           //The script file that we will compile
           System.IO.FileInfo file = new System.IO.FileInfo(@"Scripts\Wheel.cs");

           //Compile our source script file. Script engine will perform file existance checking prior to compiling.
           Boolean isCompiled = _CompileEngine.Compile(file);

           //Check for any compiler errors.
           if (!isCompiled)
           {
               Console.WriteLine(_CompileEngine.Errors);
           }
       }

Lastly, how to compile raw source code.

static void CompileSource()
        {
            //Construct an array of strings with raw source code.
            String[] sourceCode = new String[] {"namespace SampleSource {\n" + 
                "public class SampleClass {" +
                "public int Size = 20; " +
                "public Double Width" +
                "{" +
                    "get" +
                    "{" +
                      "return 8.5;" +
                    "}" +
                "}" + 
                "public void GetTireBrand() {" + 
                    "System.Windows.Forms.MessageBox.Show(\"Super Tire Co.\");" +
                 "}" + 
                 "}" + 
                 "}"
            };

            //Compile the source code
            Boolean isCompiled = _CompileEngine.Compile(sourceCode);

            //Check for any compiler errors.
            if (!isCompiled)
            {
                Console.WriteLine(_CompileEngine.Errors);
            }
        }

What’s next? I’ve already started work on implementing a IronPython Compiler Wrapper. I’m sure developers would like being able to supply a Python script engine with their application wrote in C# or VB. I’m also working on getting a Windows Phone 7 version of the engine compiled. Be nice to write your Python scripts once, include the scripts in your PC app and then ship pre-compiled scripts with your WP7 app and still have access to dynamic method invoking and property accessing.

Advertisements
Categories: Programming

rScript Engine for .NET Goes live!

December 10, 2010 Leave a comment

Last night I uploaded the initial release of the rScript Engine. With the 1.1 release, developers can quickly and easily add a script engine to their projects, supporting C# and Visual Basic scripts. Much like it’s older predesessors that I replaced, the script engine will dynamically compile scripts, Invoke Methods, Accessing Properties and Fields.

The rScript does something however that my older engine’s would not do, and that is offer support for adding any custom .NET based compiler into the engine to be used as a script compiler on the fly.

The engine is available for free with plans to add IronPython and IronRuby for scripting support.
Cross-platform support is planned as well, with Linux, Xbox 360 and Windows Phone support coming soon.
Note that Windows Phone and Xbox support will be for accessing compiled Types dynamically. Compiling of scripts is not supported by those devices, and thus won’t be available as part of the engine.

Categories: Programming