[StarTrek] What does ERR3 mean?

classic Classic list List threaded Threaded
6 messages Options
yc+
Reply | Threaded
Open this post in threaded view
|

[StarTrek] What does ERR3 mean?

yc+
I'm making a StarTrek game using Jack.

At the beginning of the game, you're supposed to enter an integer greater or equal to 1 to indicate the difficulty.

After that, the game is supposed to start and moving stars will appear on the screen.

However, when you run the program in the VMEmulator, it returns with "ERR3". What does that mean?


Reply | Threaded
Open this post in threaded view
|

Re: [StarTrek] What does ERR3 mean?

cadet1620
Administrator
Division by zero.

See Jack OS Error Codes.

--Mark
yc+
Reply | Threaded
Open this post in threaded view
|

Re: [StarTrek] What does ERR3 mean?

yc+
Got that handled!

How should I debug for this?

Reply | Threaded
Open this post in threaded view
|

Re: [StarTrek] What does ERR3 mean?

cadet1620
Administrator
yc+ wrote
How should I debug for this?

'That' segment must be in the Heap or Screen range in StarTrekGame.new.146
The supplied compiler uses the 'that' segment for array indexing. This message means that the memory address resulting from base[index] is not valid. The most likely cause is that base has not been set so its value is 0.

The easiest way to debug Jack programs in the VM Emulator is by putting Output.printXxx() statements in your code to show its progress. Look at the generated VM code and make a guess at what source line generated the VM code that failed and start putting prints there.

--Mark
yc+
Reply | Threaded
Open this post in threaded view
|

Re: [StarTrek] What does ERR3 mean?

yc+
Great! That got taken care of.

In StarTrekGame.jack (line 103): In subroutine crash: Expected (

Talking about some problem with this line of code:
let d=StarTrekGame.distanceSq(star.x, star.y, m1, m2);


What's the problem?
Reply | Threaded
Open this post in threaded view
|

Re: [StarTrek] What does ERR3 mean?

cadet1620
Administrator
yc+ wrote
In StarTrekGame.jack (line 103): In subroutine crash: Expected (

Talking about some problem with this line of code:
let d=StarTrekGame.distanceSq(star.x, star.y, m1, m2);
You can't directly access fields in an object.

You need to write methods in star's class so that you can say something like:
    let d=StarTrekGame.distanceSq(star.xValue(), star.yValue(), m1, m2);

--Mark