Table of Contents

Scripter Overview

AlterNET Scripter is a component library designed to integrate C#, Visual Basic, TypeScript, JavaScript, Python, and IronPython scripts into your WinForms and WPF .NET desktop applications. It allows extending the application logic by implementing custom functionality or automating custom tasks without recompiling and redeploying the application.

Script Execution

The main components that provide script-executing functionality for supported programming languages are: ScriptRun for C# and VisualBasic; ScriptRun for Python; ScriptRun for IronPython and ScriptRun for TypeScript and JavaScript. These components encapsulate the functionality of running standalone C#, Visual Basic, Python, IronPython, TypeScript, and JavaScript script files or projects with forms and resources; they allow referencing third-party assemblies and registering application-defined objects to be accessible in the scripts.

Scripter

Script Debugging

The following components provide a fully-featured script debugging engine for the supported programming languages: ScriptDebugger for C# and VisualBasic; ScriptDebugger for Python; ScriptDebugger for IronPython; ScriptDebugger for TypeScript and JavaScript. ScriptDebugger for debugger that relies on Debugger Adapter Protocol.

These debuggers support Start, Stop, Break and Continue commands, step-by-step execution, breakpoints, expression evaluation, viewing local variables and watches, stack tracing, and in the case of C#/VisualBasic, multiple thread debugging.

AlterNET Scripter includes a set of quick-start projects, each designed to highlight the component's specific features.

Below is a brief overview of these projects, most of them available for C#/Visual Basic, Python, IronPython, and TypeScript

AlterNET Studio - demonstrate how to run and debug script files and projects. Example files and projects are located in the demo\resources\debugger folders.

CallMethod - a set of quick-start projects for all supported languages which demonstrate how to execute script methods and pass application objects to the script.

CustomAssembly - demonstrates how to use external assemblies in the scripts

EvaluateExpression - shows how ScriptRun can evaluate expressions, which again can access some objects defined in the application

Object Reference - shows how application-defined objects can be accessed by bane from the script.

Threading - shows how scripts can run asynchronously.

DebuggerIntegration - Shows how debugger logic can be integrated into the application to debug scripts (application-independent scripts in case of C#/Visual Basic).

For C#/Visual Basic only:

DebugMyScript - demonstrates how scripts executed by the application can be debugged by a separate Script Debugger tool.

DebugRemoteScript - Shows how debugger logic can be embedded in the application to debug scripts that access the application API indirectly.

Isolated script - Shows how to load a script in the separate AppDomain so that it can be unloaded afterward and execute methods in it.

For Debugger Adapter Protocol (DAP):

CppLlvmDapDebugger - Shows how debugger logic can be integrated into the application to debug standalone C++ projects.

PythonDapDebugger - Shows how debugger logic can be integrated in the application to debug standalone Python projects.

Creating your first project

To see C# scripting in action, place the ScriptRun component on the form, and write the following code in the Button click event handler:

    scriptRun1.ScriptSource.FromScriptCode("public class ScriptTest { public static void Main() { System.Windows.Forms.MessageBox.Show(\"Hello World \");} }");
    scriptRun1.ScriptSource.WithDefaultReferences();
    scriptRun1.Run();

The first line of the code populates the Script source, the second line adds references to the most common System assemblies, and the third runs the code.