Code covered by the BSD License  

Highlights from
Soft interrupting of long computer runs

Soft interrupting of long computer runs



Long run of the program can be interrupted without any loss of data in a workspace.

function interpt(varargin)
%   INTERPT     Test of interrupt 
% The function test the global variable FLAG, which can be set by pushing
% the button BREAK by a mouse. If the button were not pushed, the function
% interpt is passed through without any interruption. In the oposite case,
% if some variables have been transfered from within the cycle, their names
% are displayed. Then, the function enters the keyboard mode, in which the
% user may test transfered variables and make any evaluations. 
%    The keyboard mode is interrupted by pushing F5 key. Afterwards, before 
% return from the function, the user is asked whether the cycle should
% continue. An offer on continuation can be confirmed by pushing 
% ENTER key, or refused by entering another key.  
% Required prerequisity:
% Function inp.m    (

% Miroslav Balda
% miroslav AT
% 2012-02-22    v.1.0   basic version

global FLAG;

if FLAG 
    if nargin>0
        disp(' Variable names:')
        name = cell(nargin,1);
        for k_=1:nargin
            name{k_} = char(inputname(k_));
            disp(['    ' name{k_}]);
            eval([name{k_} ' = varargin{k_};']);
        end % k
    end % if
    keyboard                        %   Press F5 if you wish to continue.
    FLAG = ~strcmp(inp('CONTINUE','yes'),'yes');

Contact us