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, (')',)) devices.get_file(num) logging.warning("IOCTL$() function not implemented.") raise error.RunError(error.IFC)
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, (')', )) devices.get_file(num) logging.warning("IOCTL$() function not implemented.") raise error.RunError(error.IFC)
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 = devices.get_file(num) return fp.pack(fp.Single.from_int(the_file.lof()))
def value_loc(ins): """ LOC: get file pointer. """ util.skip_white(ins) num = vartypes.pass_int_unpack(parse_bracket(ins), maxint=0xffff) util.range_check(0, 255, num) the_file = devices.get_file(num) return vartypes.pack_int(the_file.loc())
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 = devices.get_file(num, 'IR') return vartypes.bool_to_integer(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 = devices.get_file(number, file_mode) util.require_read(ins, (',',)) return screen
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 = devices.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 = state.io_state.kybd_file if util.skip_white_read_if(ins, (',',)): infile = devices.get_file(parse_file_number_opthash(ins)) util.require_read(ins, (')',)) word = bytearray(infile.read_raw(num)) if len(word) < num: # input past end raise error.RunError(error.INPUT_PAST_END) return state.basic_state.strings.store(word)
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 = state.io_state.kybd_file if util.skip_white_read_if(ins, (',', )): infile = devices.get_file(parse_file_number_opthash(ins)) util.require_read(ins, (')', )) word = bytearray(infile.read_raw(num)) if len(word) < num: # input past end raise error.RunError(error.INPUT_PAST_END) return state.basic_state.strings.store(word)