(self, args)
OPEN: open a data file.
OPEN: open a data file.
OPEN : open a data file .
def open_(self, args):
        """OPEN: open a data file."""
        first_expr = values.next_string(args)
        if next(args):
            # old syntax
            mode = first_expr[:1].upper()
            if mode not in (b'I', b'O', b'A', b'R'):
                raise error.BASICError(error.BAD_FILE_MODE)
            number = values.to_int(next(args))
            error.range_check(0, 255, number)
            name = values.next_string(args)
            access, lock = None, None
        else:
            # new syntax
            name = first_expr
            mode, access, lock = next(args), next(args), next(args)
            # AS file number clause
            number = values.to_int(next(args))
            error.range_check(0, 255, number)
        reclen, = args
        mode = mode or b'R'
        if reclen is None:
            reclen = 128
        else:
            reclen = values.to_int(reclen)
        # mode and access (if specified) must match if not a RANDOM file
        # If FOR APPEND ACCESS WRITE is specified, raises PATH/FILE ACCESS ERROR
        # If FOR and ACCESS mismatch in other ways, raises SYNTAX ERROR.
        if access:
            if mode == b'A' and access == b'W':
                raise error.BASICError(error.PATH_FILE_ACCESS_ERROR)
            elif ((mode == b'I' and access != b'R') or (mode == b'O' and access != b'W') or
                    (mode == b'A' and access != b'RW')):
                raise error.BASICError(error.STX)
        error.range_check(1, self.max_reclen, reclen)
        # can't open file 0, or beyond max_files
        error.range_check_err(1, self.max_files, number, error.BAD_FILE_NUMBER)
        self.open(number, name, b'D', mode, access, lock, reclen)
def open_ ( self , args ) : first_expr = values . next_string ( args ) if next ( args ) : # old syntax mode = first_expr [ : 1 ] . upper ( ) if mode not in ( b'I' , b'O' , b'A' , b'R' ) : raise error . BASICError ( error . BAD_FILE_MODE ) number = values . to_int ( next ( args ) ) error . range_check ( 0 , 255 , number ) name = values . next_string ( args ) access , lock = None , None else : # new syntax name = first_expr mode , access , lock = next ( args ) , next ( args ) , next ( args ) # AS file number clause number = values . to_int ( next ( args ) ) error . range_check ( 0 , 255 , number ) reclen , = args mode = mode or b'R' if reclen is None : reclen = 128 else : reclen = values . to_int ( reclen ) # mode and access (if specified) must match if not a RANDOM file # If FOR APPEND ACCESS WRITE is specified, raises PATH/FILE ACCESS ERROR # If FOR and ACCESS mismatch in other ways, raises SYNTAX ERROR. if access : if mode == b'A' and access == b'W' : raise error . BASICError ( error . PATH_FILE_ACCESS_ERROR ) elif ( ( mode == b'I' and access != b'R' ) or ( mode == b'O' and access != b'W' ) or ( mode == b'A' and access != b'RW' ) ) : raise error . BASICError ( error . STX ) error . range_check ( 1 , self . max_reclen , reclen ) # can't open file 0, or beyond max_files error . range_check_err ( 1 , self . max_files , number , error . BAD_FILE_NUMBER ) self . open ( number , name , b'D' , mode , access , lock , reclen )