%==========================================================================
% pavStartBlock asks at the beginning of each block whether we want to 
% continue or abort the task.
%
% Jennifer Swart,
% start:        26-06-2014
% last changes: 21-04-2015
%==========================================================================

% check whether to abort or continue at the beginning of each block.
if ismember(iTrial,prep.par.learn.break+1)
    iBlock = iBlock + 1;
    fprintf(logfile, 'BLOCK:\t\t\t%d   \n\n',iBlock);
    txtBreak = {'Please specify:','Continue(c) / Quit(q)'};
    disptxt(txtBreak,wd,wdw,wdh,0,0,prep.par.col.white,0,0);
            
    inBreak = true; 
    while inBreak
        WaitSecs(0.1);
        cmnd = KeyboardResponse(inf,true);
        cmnd = KbName(cmnd);
        
        if strcmpi(cmnd,'q')
            fprintf(logfile, 'Task aborted.\n\n\n');
            aborted = true; break;
        end 
        
        if any(strcmpi(cmnd,{'q','c'}))
            blackscreen;
            WaitSecs(2);
            drawfix;
            Screen(wd, 'Flip');
            WaitSecs(3);
            pavSendTrigger(prep,B,prep.par.code.resume);
            breaktime = breaktime + GetSecs - tm.learn{iPart}.break(iBlock);
            inBreak = false;
        end 
        
    end % end while inBreak.
    
end % end if ismember.