Skip to main content

XSalScript

Namespace: PPJ.Runtime.XSal

Assembly: PPJ.Runtime.XSal.50 (5.0.0.0)

Compiles and executes XSal-compatible or C#-style scripts through a shared ScriptEngine.

public class XSalScript

Example:

var script = new PPJ.Runtime.XSal.XSalScript("{ return 1 + 2; }");
string result = script.Run();
script.Dispose();

Constructors

Instance member XSalScript()

Initializes an empty script without compiling it.

Instance member XSalScript(source)

Initializes and compiles a nonempty script.

NameTypeDescription
sourceStringThe source text; null or empty input creates an empty script.

Properties

Instance member Context

Object: Gets or sets the object supplied as the script execution context.

Instance member CSharpSyntax

Boolean: Gets or sets whether new source bypasses legacy XSal syntax preprocessing.

Changing this flag does not recompile existing source.

Instance member DebugMode

Boolean: Gets or sets whether parser and interpreter errors are rethrown instead of recorded in LastError.

Instance member Handle

IntPtr: Gets a lazily allocated managed handle that keeps this script alive until Dispose releases it.

Instance member HasErrors

Boolean: Gets whether LastError contains a recorded compilation or execution error.

Static member Interpreter

ScriptEngine: Gets or sets the shared script engine, creating one lazily when no engine is assigned.

Instance member LastError

String: Gets the last recorded parser or interpreter error, or null when the latest compilation or execution cleared it.

Instance member Source

String: Gets the stored source or preprocesses and compiles newly assigned nonempty source.

Text starting and ending with braces enables CSharpSyntax. Assigning null or empty text clears Source but does not discard an already compiled script.

Methods

Instance member AddLine(line)

Appends a source line and recompiles the accumulated script.

ParameterTypeDescription
lineStringThe line to append; legacy syntax is preprocessed unless CSharpSyntax is enabled.

Returns: Boolean. True after successful compilation or for null or empty input; false after a recorded parser error.

Throws:

Instance member Dispose()

Clears the execution context and releases the managed handle when allocated.

The stored source and compiled script remain available.

Protected member Finalize()

Destructor

Static member FromHandle(handle)

Retrieves a script from a previously allocated managed handle.

ParameterTypeDescription
handleIntPtrA live handle returned by Handle.

Returns: XSalScript. The referenced script, or null for a nonpositive handle value.

Do not pass native window handles, arbitrary pointers, or handles already released by Dispose.

Instance member Run()

Executes the compiled script in the configured context.

Returns: String. The string form of the result, or an empty string for no compiled script, a null result, or a recorded interpreter error.

Throws: