Ron
August 26, 2008, 9:56am
1
I downloaded a piece of JS code that I want to run in my method.
It appears that v.4 not supports functions with arguments, like:
function product(a,b)
{
a * b
}
function callproduct()
(
answer = product(3,2)
)
This would be realy nice to have.
Regards,
Ron
Joas
August 26, 2008, 10:07am
2
Why not use the arguments-array?
function product()
{
var a = arguments[0];
var b = arguments[1];
return a * b;
}
function callproduct()
{
var answer = product(3,2);
}
Ron
August 26, 2008, 11:31am
3
Thanks for the code Joas, in fact it does the same thing.
Problem stays however that I have to rebuilt available
JS code with function arguments.
Regards,
Ron
Functions with named arguments is on the todo list…
Paul
You can define it with named arguments dynamically, like this…
function my_global_init_function() {
globals['product'] = function(a,b) {
return a*b;
}
}
Then you be able to call “globals.product(1,2)” in your code. Just be sure your init function is called before you intend to use it (like in your solution open method).
greg.