This project has moved. For the latest updates, please go here.

Question about use as a script engine

Oct 17, 2012 at 5:54 PM

Hello, I searched several javascript and find your work really awesome. I have some questions about what it can do. I wants to do the following things in javascript, by loading a user script file:

1. A complex script may need to create thread to do different things, can I create thread and control them (stop / (re)start / dispose) in javascript?

2. A complex script may include some other script-lib, does this kind of script supported?

3. Wants  to use C# List or Array in javascript, can I do it?

4. Pass data from C# to and back ?

That's what I can imagine currently.. I am really newbie of this tipic.

Thanks,

BR!

Coordinator
Nov 3, 2012 at 11:34 PM
  1. There is no support for threading in the javascript standard library, so no support in Jurassic either.  You could, however, build a web-workers style system pretty easily, with a separate ScriptEngine per thread.  See this page: http://jurassic.codeplex.com/wikipage?title=Threading%20and%20concurrency&referringTitle=Documentation
  2. Nope, sorry, no support for including other scripts (from within JavaScript) because again ECMAScript 5 doesn't support it.  But it's easy to use the ScriptEngine to execute as many scripts as you like.
  3. No, I don't support this either, sorry.
  4. There are a few ways to do this.  You can construct javascript objects in C# (Jurassic.Library.ObjectInstance) and pass them to a javascript function (Using CallGlobalFunction or Call on a FunctionInstance).  Then you can read the ObjectInstance that gets returned.  Or you could convert everything to JSON and pass that back and forth.  See this page: http://jurassic.codeplex.com/wikipage?title=Calling%20a%20JavaScript%20function%20from%20.NET&referringTitle=Documentation