Skip to content

Session: executing "GOSUB line" after entering program → strange result #184

@Marrin

Description

@Marrin

PC-BASIC version: 2.0.4

I get a strange result when entering a program in a Session and the GOSUB to a specific line. Here is a small test case:

#!/usr/bin/env python3
import pcbasic

SOURCE = """\
10 PRINT "Main"
30 PRINT 42
40 END
50 PRINT "After End"
60 PRINT "Sub"
70 RETURN
"""

def main():
    with pcbasic.Session() as session:
        session.execute(SOURCE)
        # session.execute("RUN")
        session.execute("GOSUB 60")


if __name__ == "__main__":
    main()

The output I get:

Sub
 42

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 the GOSUB is entered manually?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions