A built-in function tried to access memory outside the Heap or Screen range.

A built-in function tried to access memory outside the Heap or Screen range.

Please could someone assist me with the following issue: I was trying to test some vm files for a jack Tic-Tac-Toe application, but i got the following VM emulator error "A built-in function tried to access memory outside the Heap or Screen range" , the error can be seen in the VM emulator screenshot in the link below:

Also, the error occurs when the emulator tries to print an Array element, from the board Array in the drawBoard() method, in my TicTacToeBoard class. What is surprising is that the array, I am trying to print or use is not too big or complex, as it just has 9 elements. Below are the Jack files for my application .(The first class, in the display is the TicTacToeBoard class, while the second, situated at the end is the Main Class.) Please any help would be seriously appreciated, as i have already spent hours on this.Thanks.

/** creates a Tic-Tac-Toe board */

class TicTacToeBoard{
field Array board; //an Array to be used for board construction

That's because you are just looking at it and seeing what you WANT to see, not what is actually there. This is very common in us humans because we know what we meant to write, and so when we review it we tend to see what we believe we wrote, whether it is what we actually wrote or not.

I looked at it again and I saw one error, which was that I included the return statement inside the while block.
However, when i placed the return statement outside the while block, compiled and ran the code on the VM, the program seemed to have entered an infinite loop: it never gets to the drawBoard() method.

Also from the link, the Allman Style seems to be all about placing the place associated with a control statement on the next line, thus, if used on my constructor (and with the return statement in the new place), the code should be as in below. (However, I still have the problem of the infinite loop mentioned above). Thanks.

Thanks, I 've seen the error (i forgot to include a statement inside the while loop, to increment the while loop index!), very stupid of me. Also, i 've corrected it and tested the code and it is working as expected.