Hello shripaldalal,
JavaScript's
In general, script constructs such as JavaScript's
That said, it might be possible to expose .NET collections to VBScript's
"Object not a collection" is a VBScript-specific error message. Are you sure you're seeing it when using JScript?
Thanks!
Can this work in V8 ? I don't mind using Count and Item properties for iteration but I would prefer this more.
JavaScript's
for/in
statement does work, but it doesn't do what you think it does. It iterates through the names of an object's properties. For a .NET DataRowCollection
, it returns "Add", "Clear", "Contains", etc. It returns strings, and since you can't assign a string to a .NET property of type DataRow
, you get "Invalid field assignment".In general, script constructs such as JavaScript's
for/in
and VBScript's for each
were designed for script object models that are very different from .NET's. ClearScript aims to provide full access to .NET objects and types; it doesn't (and often can't) automatically create ideal APIs for specific script languages.That said, it might be possible to expose .NET collections to VBScript's
for each
. We're looking into it.
If I dont declare the variables it gives error as: Object not a collection at Microsoft.ClearScript.ScriptEngine
"Object not a collection" is a VBScript-specific error message. Are you sure you're seeing it when using JScript?
Thanks!