Click or drag to resize

ScriptEngineEvaluate(String, Boolean, String) Method

Evaluates script code with an associated document name, optionally discarding the document after execution.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.4.5
Syntax
public Object Evaluate(
	string documentName,
	bool discard,
	string code
)

Parameters

documentName  String
A document name for the script code. Currently, this name is used only as a label in presentation contexts such as debugger user interfaces.
discard  Boolean
True to discard the script document after execution, false otherwise.
code  String
The script code to evaluate.

Return Value

Object
The result value.

Implements

IScriptEngineEvaluate(String, Boolean, String)
Remarks

In some script languages the distinction between statements and expressions is significant but ambiguous for certain syntactic elements. This method always interprets the specified script code as an expression.

If a debugger is attached, it will present the specified script code to the user as a document with the specified name. Discarding this document removes it from view but has no effect on the script engine. Only Windows Script engines honor discard.

The following table summarizes the types of result values that script code can return.
TypeReturned AsRemarks
StringSystem.StringN/A
BooleanSystem.BooleanN/A
NumberSystem.Int32 or System.Double Other numeric types are possible. The exact conversions between script and .NET numeric types are defined by the script engine.
Null ReferencenullN/A
UndefinedUndefined This represents JavaScript's undefined, VBScript's Empty, etc.
VoidVoidResult This is returned when script code forwards the result of a host method that returns no value.
Host ObjectNative .NET type This includes all .NET types not mentioned above, including value types (enums, structs, etc.), and instances of all other classes. Script code can only create these objects by invoking a host method or constructor. They are returned to the host in their native .NET form.
Script ObjectScriptObject This includes all native script objects that have no .NET representation. C#'s dynamic keyword provides a convenient way to access them.
OtherUnspecified This includes host types and other ClearScript-specific objects intended for script code use only. It may also include language-specific values that the ClearScript library does not support.

See Also