Hi ,
How can we give input from user for the expression .
Thank you.
How can we give input from user for the expression .
Thank you.
var input = ReadLine();
var result = engine.Evaluate(input = list.ToString());
using (var engine = new V8ScriptEngine())
{
WriteLine("Enter input");
var input = ReadLine();
foreach (PersonList person in list)
{
var output= engine.Evaluate((input) = (person.name));
WriteLine(output);
}
input is typing by user some data for the script to process i.e., name="siva"input
and person.name
to a script function or expression.myFunction
samples above).engine.Evaluate(string.Format("myFunction('{0}', '{1}')", input, person.name));
class foo { publicstring A { get; set; } } [Test] publicvirtualvoid Test_ToString_v8_base() { using(var run = new V8ScriptEngine()) { var tsBefore = run.Evaluate("toString()"); Assert.AreEqual("[object Undefined]", tsBefore);// is it ok ? run.Execute(@"function toString(){return 'AAA';}"); var tsBefore2 = run.Evaluate("toString()"); Assert.AreEqual("AAA", tsBefore2); var foo = new foo(); run.AddHostObject("foo", HostItemFlags.GlobalMembers, foo); var tsAfter = run.Evaluate("toString()"); run.Execute(@"function toString(){return 'BBB';}"); var tsAfter2 = run.Evaluate("toString()"); Assert.AreEqual("BBB", tsAfter2);// NOK: it is still [object Undefined] Assert.AreEqual("AAA", tsAfter); // don't know what to expect here.. } }
#
# Fatal error in ..\..\src\api.cc, line 2905
# CHECK(!(isolate)->external_caught_exception()) failed
#
Exception de première chance à 0x00000000 dans nunit.exe : 0xC0000005: Violation d'accès à l'emplacement 0x0000000000000000.
Exception non gérée à 0x00000000 dans nunit.exe : 0xC0000005: Violation d'accès à l'emplacement 0x0000000000000000.
class MissingSetter { privatestring _back_title; public MissingSetter(string title) { _back_title = title; } publicstring title { get { return _back_title; } } } [Test] publicvirtualvoid Test_InterfaceAndScriptAccess_basic([Values(false, true)] bool withPropertyBag) { using (var run0 = new V8ScriptEngine()) { if (withPropertyBag) run0.AddHostObject("bag", HostItemFlags.GlobalMembers, new PropertyBag()); run0.AddHostObject("__other_page", HostItemFlags.GlobalMembers, new MissingSetter("BBB")); Assert.AreEqual("BBB", run0.Evaluate("title")); Assert.Throws<Microsoft.ClearScript.ScriptEngineException>(delegate { run0.Execute("title = 'AAA'"); }); Assert.AreEqual("BBB", run0.Evaluate("title")); } }
VBScriptEngine scriptEngine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging);
double byRefValue = 10.0;
scriptEngine.Execute(@"sub TestSub(ByRef MyParam) : MyParam=20.0 : end sub");
scriptEngine.Script.TestSub(ref byRefValue);
Basically what I was trying to accomplish , was the double values should end up being set to 20.0 , but it always remains at 10.0