Quantcast
Channel: ClearScript
Viewing all 2297 articles
Browse latest View live

New Post: Byte converted to Int

$
0
0
Hi ravetam,

There are a couple of ways to do it. First, you can use HostFunctions.toByte():
engine.AddHostObject("host", new HostFunctions());
engine.Execute(@"
    var b = host.toByte(162);
");
Another way is to use a host variable:
engine.AddHostType("Byte", typeof(Byte));
engine.Execute(@"
    var b = host.newVar(Byte);
    b.value = 162;
");
Cheers!

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
0
0
Thanks for your time.

Do you think that if I use .NET 4.5 would create this problem? I downloaded the project and it's using 4.0.

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
0
0
Hi scuty,

We have no reason to believe that .NET 4.5 is the cause of this issue, but it's difficult to be sure without knowing the true cause.

By the way, the ClearScript ReadMe contains our recommended procedure for integrating ClearScript into ASP.NET projects, and the discussion thread linked above includes our suggestions for users of the ClearScript.V8 NuGet package.

Good luck!

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
0
0
Hi,

Doing what the ReadMe said solved the problem. Thanks! Great project!

New Post: Cannot add v8-ia32.dll, v8-x64.dll as references in Visual Studio

$
0
0
Hi, there.

I tried adding v8-ia32.dll, v8-x64.add as references in Visual Studio.
However I got the error: "Please make sure that the file is accessible, and that is is a valid assembly or COM component."

How do I use V8ScriptEngine?

My operations was as follows:
  1. Downloaded ClearScript-5.3.11
  2. Executed V8Update.cmd on Visual Studio developer command line.
  3. Opened the solution file 'ClearScript.sln'
  4. Built the solution (Release mode).
  5. Created new WPF project.
  6. Added v8-ia32.dll, v8-x64.dll as references to the new project.
  7. I encountered the above problem.
My environment is as follows:
ClearScript: 5.3.11
Visual Studio: 2013
OS: Windows 7 (64bit)

New Post: Cannot add v8-ia32.dll, v8-x64.dll as references in Visual Studio

$
0
0
Hi knhr,

You should only add a project reference to the main ClearScript assembly, ClearScript.dll.

If you wish to use ClearScript's V8 support, you must also copy the V8 assemblies (ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, and v8-x64.dll) to your application's directory, but referencing them from your project is unnecessary.

Please see the ClearScript ReadMe for more information about integrating and deploying ClearScript with your application.

Cheers!

New Post: Cannot add v8-ia32.dll, v8-x64.dll as references in Visual Studio

$
0
0
Thanks for your prompt reply.
It works :D

I didn't notice that V8 assemblies needs only copying to application's directory (,not adding to a project as references).
I'm sorry for lacking concentration.

Thanks!!

New Post: Cannot use Action/Function in PropertBag in JScript/V8

$
0
0
I have created a new class that inherits a PropertyBag (but tried it direct also) so that I can create some standard Actions or Functions automatically when the Bag is created.
Code Below :
        public class ConfigBag : PropertyBag
        {
            private const String stdkeys = "bagkeys,doit";
            public ConfigBag()
            {
                this["bagkeys"] = new Func<String>(() => this.bagkeys());
                this["doit"] = new Action(() => this.doit());
            }

            public String bagkeys()
            {
                List<String> keys = this.Keys.ToList();
                foreach (String k in stdkeys.Split(new char[] { ',' }))
                {
                    keys.Remove(k);
                }
                return String.Join(",", keys.ToArray());                
            }

            public void doit()
            {
                Debug.Print("Got here : ");
            }
        }

            public ConfigBag newbag()
            {
                ConfigBag bag = new ConfigBag();
                bag.Add("Name", "Richard");
                bag.Add("Age", 21);
                bag.Add("FootBall", "Arsenal");
                return bag;
            }
When I execute this from VBScript
x = api.newbag()
debug.log(x.Name)
debug.log(x.Age)
debug.log(x.bagkeys)
debug.log(x.doit)
It all works fine ...

Name,Age,FootBall

But when I execute it from JScript of V8 (exactly the same code) I get

System.Func`1[System.String]

Hitting my head against a wall here! Am I missing something? I am trying to make a standard interface between VBScript and JScript or V8. I need the PropertyBag type functionality which works but I cannot do things like use ".ContainsKey" plus like the idea of adding additional functionality.

New Post: Cannot use Action/Function in PropertBag in JScript/V8

$
0
0
Hello egooner,

JavaScript syntax requires a parenthesized argument list for invocation:
debug.log(x.bagkeys())
Otherwise you're just printing out the delegate's string representation.

Good luck!

New Post: Cannot use Action/Function in PropertBag in JScript/V8

$
0
0
Ok - so I figured out that if I can from JS using x.bagkeys() instead of x.bagkeys it works!
But am I overcomplicating matters and should x.bagkeys work without the () appended as it does with VBScript?

New Post: Cannot use Action/Function in PropertBag in JScript/V8

$
0
0
Thanks - figured that just before your post but thanks anyway ... am I missing something though? Why can I not access the PropertyBag's own Keys function is that intentional?
                engine.AddHostObject("debug", jsapi.mydebug);          
                engine.AddHostObject("console", jsapi.console);
                engine.AddHostObject("document", jsapi.document);
                engine.AddHostType("IndexedList", typeof(IndexedList<Object>));
                engine.AddHostType("ConfigBag", typeof(ConfigBag));
I did try also with PropertyBag added in the AddHostObject but that did not expose Keys either!?

New Post: Byte converted to Int

New Post: Cannot use Action/Function in PropertBag in JScript/V8

$
0
0
Hi egooner,

Why can I not access the PropertyBag's own Keys function is that intentional?

Yes, that's intentional. Property bags are special in that they expose their keys as if they were members. Exposing their members within the same namespace could create conflict or ambiguity.

If you need to enumerate a property bag, you can use JavaScript's for...in statement.

Another possibility is to expose a property bag's dictionary interface separately from the property bag itself:
var foo = new PropertyBag();
engine.AddHostObject("foo", foo);
engine.AddRestrictedHostObject("fooDict", (IDictionary<string, object>)foo);
and then, in JavaScript:
foo.bar = 123;
if (fooDict.Keys.Contains('bar')) {
    // do something
}
Cheers!

New Post: Culture of Windows Script Engine

$
0
0
Please add ability to change the default cultureinfo that passed to the windows script engine. An application that use a script engine can have different culture from a default culture that internally use windows script engine. That cause to problems in scripts that uses with currency/datetime formatting's

New Post: Culture of Windows Script Engine

$
0
0
Hi ifle,

Can you provide a sample script that would be affected by this setting?

Thanks!

New Post: Culture of Windows Script Engine

$
0
0
Function Money_Type_2(money)
If IsNumeric(money) Then
   Money_Type_2 = FormatCurrency(money, 2, -1, -1, -2)
End If
End Function
In my modificated version of ClearScript I pass to the script engine the CultureInfo of the Thread and all works as expected.

New Post: Culture of Windows Script Engine

$
0
0
I pass to the script engine the CultureInfo

You mean, via IActiveScriptSite::GetLCID()? Or is there another way?

New Post: Culture of Windows Script Engine

$
0
0
Yes, I mean via IActiveScriptSite::GetLCID.
Are you able to reproduce this issue?

New Post: Culture of Windows Script Engine

$
0
0
Yes. The only issue is that the engine seems to query this value only when the site is attached - that is, in the WindowsScriptEngine constructor. Would it be sufficient to use the current culture (or UI culture) in all cases? Or do you need to use specific cultures and/or change the culture after constructing the engine?

New Post: Culture of Windows Script Engine

$
0
0
In my case the current culture is enough
Viewing all 2297 articles
Browse latest View live




Latest Images