def auto_step(): """ Generate an AUTO line number and wait for input. """ numstr = str(state.basic_state.auto_linenum) console.write(numstr) if state.basic_state.auto_linenum in state.basic_state.line_numbers: console.write('*') line = bytearray(console.wait_screenline(from_start=True)) if line[:len(numstr)+1] == numstr+'*': line[len(numstr)] = ' ' else: console.write(' ') line = bytearray(console.wait_screenline(from_start=True)) # run or store it; don't clear lines or raise undefined line number state.basic_state.direct_line = tokenise.tokenise_line(line) c = util.peek(state.basic_state.direct_line) if c == '\0': # check for lines starting with numbers (6553 6) and empty lines empty, scanline = program.check_number_start(state.basic_state.direct_line) if not empty: program.store_line(state.basic_state.direct_line) reset.clear() state.basic_state.auto_linenum = scanline + state.basic_state.auto_increment elif c != '': # it is a command, go and execute state.basic_state.execute_mode = True
def auto_step(self): """ Generate an AUTO line number and wait for input. """ numstr = str(state.basic_state.auto_linenum) console.write(numstr) if state.basic_state.auto_linenum in state.basic_state.line_numbers: console.write('*') line = bytearray(console.wait_screenline(from_start=True)) if line[:len(numstr)+1] == numstr+'*': line[len(numstr)] = ' ' else: console.write(' ') line = bytearray(console.wait_screenline(from_start=True)) # run or store it; don't clear lines or raise undefined line number state.basic_state.direct_line = tokenise.tokenise_line(line) c = util.peek(state.basic_state.direct_line) if c == '\0': # check for lines starting with numbers (6553 6) and empty lines empty, scanline = program.check_number_start(state.basic_state.direct_line) if not empty: program.store_line(state.basic_state.direct_line) reset.clear() state.basic_state.auto_linenum = scanline + state.basic_state.auto_increment elif c != '': # it is a command, go and execute state.basic_state.parse_mode = True
def merge(g): """ Merge program from ascii or utf8 (if utf8_files is True) stream. """ while True: line = g.read_line() if line is None: break linebuf = tokenise.tokenise_line(line) if linebuf.read(1) == '\0': # line starts with a number, add to program memory; store_line seeks to 1 first store_line(linebuf) else: # we have read the : if util.skip_white(linebuf) not in tk.end_line: raise error.RunError(error.DIRECT_STATEMENT_IN_FILE)
def store_line(self, line): """ Store a program line or schedule a command line for execution. """ if not line: return True state.basic_state.direct_line = tokenise.tokenise_line(line) c = util.peek(state.basic_state.direct_line) if c == '\0': # check for lines starting with numbers (6553 6) and empty lines program.check_number_start(state.basic_state.direct_line) program.store_line(state.basic_state.direct_line) reset.clear() elif c != '': # it is a command, go and execute state.basic_state.parse_mode = True return not state.basic_state.parse_mode
def store_line(line): """ Store a program line or schedule a command line for execution. """ if not line: return True state.basic_state.direct_line = tokenise.tokenise_line(line) c = util.peek(state.basic_state.direct_line) if c == '\0': # check for lines starting with numbers (6553 6) and empty lines program.check_number_start(state.basic_state.direct_line) program.store_line(state.basic_state.direct_line) reset.clear() elif c != '': # it is a command, go and execute state.basic_state.execute_mode = True return not state.basic_state.execute_mode
def load_ascii_file(g, first_char=''): """ Load an ascii-codepage or utf8 (if utf8_files is True) encoded program from g. """ eof = False lg = LineGetter(g, universal_newline, utf8=utf8_files) while not eof: line, eof = lg.get_line() line, first_char = first_char + line, '' linebuf = tokenise.tokenise_line(line) if linebuf.read(1) == '\0': # line starts with a number, add to program memory; store_line seeks to 1 first store_line(linebuf) else: # we have read the : if util.skip_white(linebuf) not in util.end_line: # direct statement in file raise error.RunError(66)
def merge(g): """ Merge program from ascii or utf8 (if utf8_files is True) stream. """ while True: line = g.read_line() if line is None: break #line, first_char = first_char + line, '' linebuf = tokenise.tokenise_line(line) if linebuf.read(1) == '\0': # line starts with a number, add to program memory; store_line seeks to 1 first store_line(linebuf) else: # we have read the : if util.skip_white(linebuf) not in util.end_line: # direct statement in file raise error.RunError(66)
def watch(expr): """ Add an expression to the watch list. """ outs = tokenise.tokenise_line('?'+expr) watch_list.append((expr, outs))
def watch(expr): """ Add an expression to the watch list. """ outs = tokenise.tokenise_line('?' + expr) watch_list.append((expr, outs))