Skip to content
Permalink
Browse files

Reviewed after Irmen observation + bug fix (2)

  • Loading branch information...
daitangio committed Mar 19, 2019
1 parent 588d12e commit 1eab0ada68ae2322bea96194b78c2e1db28dc23a
Showing with 6 additions and 9 deletions.
  1. +5 −8 pyc64/basic.py
  2. +1 −1 tests/on_goto.py
@@ -414,8 +414,8 @@ def execute_goto(self, cmd):
raise GotoLineException(self.program_lines.index(line))
"""
on <index-1-based> goto|gosub <line1>,<line2>
if index evaluate to 1 the execution proceed on line1
"""
def execute_on_goto_gosub(self,cmd):
gosub=False
@@ -437,17 +437,15 @@ def execute_on_goto_gosub(self,cmd):
else:
raise BasicError("syntax")
targetLineList=targetLineList.strip()
# Arrayz...ize it
# Make a tuple of the target list
lineTargetTuple=eval("("+targetLineList+")")
goInx=cmd.find("go")
expr=cmd[0:goInx]
print("lineTargetTuple= %s expr= %s " % (lineTargetTuple, str(expr)))
# Make a zero-based index
onGoIndex=int(eval(expr))-1
expr=cmd[0:goInx]
# eval the on <expr> goto part
onGoIndex=int(eval(expr,self.symbols))-1
line=lineTargetTuple[onGoIndex]
if gosub==False:
if not self.running_program:
# do a run instead
self.execute_run("run " + str(line))
else:
if line not in self.program:
@@ -648,7 +646,6 @@ def execute_load(self, cmd):
if program and not isinstance(program, dict):
raise BasicError("invalid file type")
self.program = program
# print("LOADED:"+str(program))

def execute_dos(self, cmd):
# to show floppy contents without clobbering basic program like LOAD"$",8 would
@@ -29,7 +29,7 @@ def test_on_goto1(self):
self.assertEqual(3,b.next_run_line_idx)
#b.execute_run("run")
# print("***"+str(b.))
# TODO Implement a silly test program
# TODO Implement a silly test program to test the on expr syntax

if __name__ == '__main__':
unittest.main()

0 comments on commit 1eab0ad

Please sign in to comment.
You can’t perform that action at this time.