예제 #1
0
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)   
예제 #2
0
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() )
예제 #3
0
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())
예제 #4
0
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        
예제 #5
0
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