Howdy All,
I would like to pass a variable from one function to another function, change this variable in the second function and when returned to the first function the value would have been changed here.
function f_main()
{
var i = 1;
var retVal = true;
..
retVal = f_sub_function(i);
alert("The Value Is : " + i);
..
}
function f_sub_function(iCnt)
{
..
iCnt = 37;
..
return true;
}
When I run this I would like the alert to show me a value = 37.
This is like a pointer in C, I have been trying it with no success however it did work for an array. I passed the name of the array from one function to another and was able to change the values of the array in the second function and the changed values would show up in the first function. Now, this is very similar to C as the name of an array is the address of an array. In C, to pass the address rather than the value, you would put an '&' beforehand. So effectively I am looking for the JavaScript equivalent of '&'
Thanks & Regards
Skydive
I would like to pass a variable from one function to another function, change this variable in the second function and when returned to the first function the value would have been changed here.
function f_main()
{
var i = 1;
var retVal = true;
..
retVal = f_sub_function(i);
alert("The Value Is : " + i);
..
}
function f_sub_function(iCnt)
{
..
iCnt = 37;
..
return true;
}
When I run this I would like the alert to show me a value = 37.
This is like a pointer in C, I have been trying it with no success however it did work for an array. I passed the name of the array from one function to another and was able to change the values of the array in the second function and the changed values would show up in the first function. Now, this is very similar to C as the name of an array is the address of an array. In C, to pass the address rather than the value, you would put an '&' beforehand. So effectively I am looking for the JavaScript equivalent of '&'
Thanks & Regards
Skydive