我在松鼠代码中调用了一个简单的函数,但这似乎没有按预期工作。带参数调用函数不会影响原始变量。'counter1' 只是保持相同的值。在 javascript 中这会起作用,那么为什么这在 Squirrel 中不起作用呢?
// declare test variable
counter1 <- 100;
function impLoop() {
// function call to update these variables - this is not working!
changeValue(counter1);
// this just displays the original value: 100
server.log("counter 1 is now " + counter1);
// schedule the loop to run again (this is an imp function)
imp.wakeup(1, impLoop);
}
function changeValue(val1){
val1 = val1+25;
// this displays 125, but the variable 'counter1' is not updated?
server.log("val1 is now " + val1);
}