There's no such thing as passing arguments by reference in JScript. Instead, depending on the variable type, variables are changed or recreated. This is what we call "immutable" types.
For example, the string type is immutable: you can't change its value after you create one. Instead, all operations you do on the string actually create a new string:
js code:
var string = "Hello";
string += " world";
In this example, by appending "world" to string, you create a new string "Hello world" instead of changing it. The effect isn't very noticeable here, but it is when you use the value in more than one place.
js code:
var obj = {
foo: "bar"
};
var string = obj.foo; // string holds "bar"
string += "tender"; // string is now a new string "bartender"
// obj.prop hasn't changed and is still "bar"
Here, an object with a string property is defined and then the property value is assigned to a variable. When an operation is performed on this variable, a new string is created which means that the object property stays intact. Therefore you don't have to worry about the object properties accidentally being changed because you're changing a variable holding a property.
The basic value types in JScript are immutable: number, string, boolean,... However objects an functions are pointer types, meaning they are always passed by reference.
js code:
var obj = {
foo: "bar"
};
var newobj = obj; // newobj now also points to obj
newobj.foo = "bartender";
//obj.foo has also changed to "bartender"
Instead of copying the data from obj to a new object, newobj just points to the same data as obj. Therefore, changing a property on newobj also changed obj since they're exactly the same.
Now, a possible solution to your problem would be to pass the string argument as a property of a containing object and let your DLL change the property on that object instead. When your DLL function finishes, the data in the JScript object should be changed by the DLL, allowing you to read the new string value from the object. Your script would look something like this:
js code:
var obj = {
foo: "bar"
};
var x = new ActiveXObject("MyScript.MyClass");
x.DoIt( obj );
// obj.foo nows hold the changed value
I don't know how you implemented your DLL interactions or how a JScript object is received in the DLL function - I haven't used DLLs a lot in my own scripts. I believe this should get you started.