def value_ioctl(ins): """ IOCTL$: read device control string response; not implemented. """ util.require_read(ins, ('$',)) util.require_read(ins, ('(',)) num = parse_file_number_opthash(ins) util.require_read(ins, (')',)) iolayer.get_file(num) logging.warning("IOCTL$() function not implemented.") raise error.RunError(5)
def value_lof(ins): """ LOF: get length of file. """ util.skip_white(ins) num = vartypes.pass_int_unpack(parse_bracket(ins), maxint=0xffff) util.range_check(0, 255, num) the_file = iolayer.get_file(num) return vartypes.pack_int(the_file.lof() )
def value_eof(ins): """ EOF: get end-of-file. """ util.skip_white(ins) num = vartypes.pass_int_unpack(parse_bracket(ins), maxint=0xffff) if num == 0: return vartypes.null['%'] util.range_check(0, 255, num) the_file = iolayer.get_file(num, 'IR') return vartypes.bool_to_int_keep(the_file.eof())
def parse_file_number(ins, file_mode='IOAR'): """ Helper function: parse a file number and retrieve the file object. """ screen = None if util.skip_white_read_if(ins, ('#',)): number = vartypes.pass_int_unpack(parse_expression(ins)) util.range_check(0, 255, number) screen = iolayer.get_file(number, file_mode) util.require_read(ins, (',',)) return screen
def value_input(ins): """ INPUT$: get characters from the keyboard or a file. """ util.require_read(ins, ('$',)) util.require_read(ins, ('(',)) num = vartypes.pass_int_unpack(parse_expression(ins)) util.range_check(1, 255, num) infile = backend.kybd_file if util.skip_white_read_if(ins, (',',)): infile = iolayer.get_file(parse_file_number_opthash(ins)) util.require_read(ins, (')',)) word = vartypes.pack_string(bytearray(infile.read_raw(num))) if len(word) < num: # input past end raise error.RunError(62) return word