(self, args)
CHAIN: load program and chain execution.
CHAIN: load program and chain execution.
CHAIN : load program and chain execution .
def chain_(self, args):
        """CHAIN: load program and chain execution."""
        merge = next(args)
        name = values.next_string(args)
        jumpnum = next(args)
        if jumpnum is not None:
            jumpnum = values.to_int(jumpnum, unsigned=True)
        common_all, delete_lines = next(args), next(args)
        from_line, to_line = delete_lines if delete_lines else (None, None)
        if to_line is not None and to_line not in self.program.line_numbers:
            raise error.BASICError(error.IFC)
        list(args)
        if self.program.protected and merge:
            raise error.BASICError(error.IFC)
        # gather COMMON declarations
        commons = self.interpreter.gather_commons()
        with self.memory.preserve_commons(commons, common_all):
            # preserve DEFtype on MERGE
            # functions are cleared except when CHAIN ... ALL is specified
            # OPTION BASE is preserved when there are common variables
            self._clear_all(
                    preserve_functions=common_all,
                    preserve_base=(commons or common_all),
                    preserve_deftype=merge)
            # load new program
            with self.files.open(0, name, filetype=b'ABP', mode=b'I') as f:
                if delete_lines:
                    # delete lines from existing code before merge
                    # (without MERGE, this is pointless)
                    self.program.delete(*delete_lines)
                if merge:
                    self.program.merge(f)
                else:
                    self.program.load(f)
                # clear all program stacks
                self.interpreter.clear_stacks_and_pointers()
                # don't close files!
                # RUN
                self.interpreter.jump(jumpnum, err=error.IFC)
        # ensure newly allocated strings are not considered temporary
        # e.g. code strings in the old program become allocated strings in the new
        self.strings.fix_temporaries()
def chain_ ( self , args ) : merge = next ( args ) name = values . next_string ( args ) jumpnum = next ( args ) if jumpnum is not None : jumpnum = values . to_int ( jumpnum , unsigned = True ) common_all , delete_lines = next ( args ) , next ( args ) from_line , to_line = delete_lines if delete_lines else ( None , None ) if to_line is not None and to_line not in self . program . line_numbers : raise error . BASICError ( error . IFC ) list ( args ) if self . program . protected and merge : raise error . BASICError ( error . IFC ) # gather COMMON declarations commons = self . interpreter . gather_commons ( ) with self . memory . preserve_commons ( commons , common_all ) : # preserve DEFtype on MERGE # functions are cleared except when CHAIN ... ALL is specified # OPTION BASE is preserved when there are common variables self . _clear_all ( preserve_functions = common_all , preserve_base = ( commons or common_all ) , preserve_deftype = merge ) # load new program with self . files . open ( 0 , name , filetype = b'ABP' , mode = b'I' ) as f : if delete_lines : # delete lines from existing code before merge # (without MERGE, this is pointless) self . program . delete ( * delete_lines ) if merge : self . program . merge ( f ) else : self . program . load ( f ) # clear all program stacks self . interpreter . clear_stacks_and_pointers ( ) # don't close files! # RUN self . interpreter . jump ( jumpnum , err = error . IFC ) # ensure newly allocated strings are not considered temporary # e.g. code strings in the old program become allocated strings in the new self . strings . fix_temporaries ( )