Closed Marrin closed 2 years ago
Thanks, that's odd indeed. Your expectation is correct.
It does the wrong thing on the prompt as well so the problem is not specific to calling from the Session interface, it's a problem with the program pointer in the GOSUB
or RETURN
implementation itself in version 2.x. Version 1.x did the right thing here.
It looks like the runmode flag gets set on executing the GOSUB
in direct mode, which means the RETURN
jumps back to the program stream rather than the direct line. The weird return location arises because it records its stream position in the direct line on the jump (after a tokenised :GOSUB 60
), then jumps to that position in the programme stream, which ends up on the second line of the program in this case.
The issue is that Interpreter.jump()
sets Interpreter.run_mode
, so the original runmode needs to be stored before executing the jump. I have a fix.
Fixed by commit 52e24aa0. Thanks for reporting!
PC-BASIC version: 2.0.4
I get a strange result when entering a program in a
Session
and theGOSUB
to a specific line. Here is a small test case:The output I get:
What I expected was just the "Sub" without the 42 from line 30. And extra confusing is that "Main" is not printed. So why is the
RETURN
apparently jumping to line 20 instead of just return to the ”prompt” like it is done if the program and theGOSUB
is entered manually?