Null error when passing parameters between methods -
03-31-2012, 07:45 PM
Hi all! I am working on a program that is from the "Learning to Program with Alice" textbook. I and several of my classmates have come across an error in a particular program. In the program there are several world methods that are called to have Zeus zap an object that is clicked with the mouse. The program passes the target between methods to perform the zap. Once and item is clicked however, I get an error "Alice has detected a problem with your world: target value must not be null" If I change the code to only work when one named target is clicked I get the attached error code. I have included the world for reference. I am using Alice 2.2 for Windows with the textbook.
I saw in the troubleshooting thread that this is a known bug in Alice 2.2 and should be fixed in the update of 3/1/12 - I'm going to try downloading again.
Just make a new variable of the same data type as the parameter being passed (local and global variables work), set the variable's value to the parameter, then use the variable as the value for the parameter of the method call.