
function ok(ax)

%editglob
global EDIT_MODE CURRX DISP YAXIS BADBIN BADBIN_BAK PFLAG
global LASTCOMM LASTPLOT

if ~EDIT_MODE
  error('You are not in edit mode.  Set EDIT_MODE = 1 to enable.')
end

if nargin < 1
  if isempty(CURRX)
    error('You must plot a variable first before running this without args')
  end
   if v4,
        disp('Click on upper left and bottom right corners to select region')
        [x y] = ginput(2);
        ax = [x(1) x(2) y(2) y(1)];
   else
      ax = mousebox;
   end

end

[pmin pmax bmin bmax] = inside1(CURRX+DISP, YAXIS, ax);
if ~isempty(pmax)
  BADBIN_BAK = BADBIN;
  BADBIN(bmin:bmax,pmin:pmax) = PFLAG(bmin:bmax,pmin:pmax); % can't undo PFLAG
  LASTCOMM = 'badbin';
  eval(LASTPLOT)
end


