(self, number, param, filetype, mode, access, lock, reclen, seg, offset, length, field)
Open a file on tape.
Open a file on tape.
Open a file on tape .
def open(self, number, param, filetype, mode, access, lock, reclen, seg, offset, length, field):
        """Open a file on tape."""
        if not self.tapestream:
            raise error.BASICError(error.DEVICE_UNAVAILABLE)
        if self.tapestream.is_open:
            raise error.BASICError(error.FILE_ALREADY_OPEN)
        if set(iterchar(param)) & self._illegal_chars:
            # Cassette BASIC throws bad file NUMBER, for some reason.
            raise error.BASICError(error.BAD_FILE_NUMBER)
        try:
            if mode == b'O':
                self.tapestream.open_write(param, filetype, seg, offset, length)
            elif mode == b'I':
                _, filetype, seg, offset, length = self._search(param, filetype)
            else:
                raise error.BASICError(error.BAD_FILE_MODE)
        except EnvironmentError:
            raise error.BASICError(error.DEVICE_IO_ERROR)
        if filetype == b'D':
            return CASTextFile(self.tapestream, filetype, mode)
        elif filetype == b'A':
            return CASTextFile(self.tapestream, filetype, mode)
        else:
            return CASBinaryFile(self.tapestream, filetype, mode, seg, offset, length)
def open ( self , number , param , filetype , mode , access , lock , reclen , seg , offset , length , field ) : if not self . tapestream : raise error . BASICError ( error . DEVICE_UNAVAILABLE ) if self . tapestream . is_open : raise error . BASICError ( error . FILE_ALREADY_OPEN ) if set ( iterchar ( param ) ) & self . _illegal_chars : # Cassette BASIC throws bad file NUMBER, for some reason. raise error . BASICError ( error . BAD_FILE_NUMBER ) try : if mode == b'O' : self . tapestream . open_write ( param , filetype , seg , offset , length ) elif mode == b'I' : _ , filetype , seg , offset , length = self . _search ( param , filetype ) else : raise error . BASICError ( error . BAD_FILE_MODE ) except EnvironmentError : raise error . BASICError ( error . DEVICE_IO_ERROR ) if filetype == b'D' : return CASTextFile ( self . tapestream , filetype , mode ) elif filetype == b'A' : return CASTextFile ( self . tapestream , filetype , mode ) else : return CASBinaryFile ( self . tapestream , filetype , mode , seg , offset , length )