function buttonadjustbaselineBLA(hObject, eventdata, Empty_Button, Buttons, AxesRAW, AxesZLF, ZeroFunction, ZerolineText, calcp)
data = get(Empty_Button,'UserData');

if (isfield(data,'isdata')*isfield(data,'isbd') == 1) && (data.isdata*data.isbd == 1)
    
    [k,n] = size(data.D);
    
    bdi = [];
    for i=1:data.nobd
        bdi = [bdi data.ibd(i,1):data.ibd(i,2)];
    end
    bdi = sort(unique(bdi));
    nbdi = length(bdi);
    
    opt = get(ZeroFunction, 'Value')-1;
    
    fprintf(' C routine (AdjustBaseline) in progress ... (press CTRL + C to cancel) ... ');
    set(hObject,'Enable','off');
    
    stime = cputime;
    set(gcf,'Pointer','Watch');
    pause(0.5);
    
    actpwd = pwd;
    cd(calcp);
    
    dlmwrite('wrap/allg.txt',[k; n; nbdi],'precision','%d');
    dlmwrite('wrap/bdi.txt',bdi','precision','%d','delimiter',' ');
    dlmwrite('wrap/x.txt',data.x,'precision','%15.15e','delimiter',' ');
    dlmwrite('wrap/D.txt',data.D,'precision','%15.15e','delimiter',' ');
    dlmwrite('wrap/tim.txt',0,'precision','%d');
    
    arch = computer('arch');
    
    if (strcmp(arch,'maci64') == 1) || (strcmp(arch,'maca64') == 1)
        system(['./AdjustBaselineM64.exe ',num2str(opt)]);
    elseif strcmp(arch,'win32') == 1
        system(['AdjustBaselineW32.exe ',num2str(opt)]);
    elseif strcmp(arch,'win64') == 1
        system(['AdjustBaselineW64.exe ',num2str(opt)]);
    elseif strcmp(arch,'glnx86') == 1
        system(['./AdjustBaselineU32.exe ',num2str(opt)]);
    elseif strcmp(arch,'glnxa64') == 1
        system(['./AdjustBaselineU64.exe ',num2str(opt)]);
    else
        fprintf(2,'No executable version for this type of system.\n');
        
        set(gcf,'Pointer','arrow');
        cd(actpwd);
        return;
    end
    set(gcf,'Pointer','arrow');
    set(hObject,'Enable','on');
    
    tim = load('wrap/tim.txt');
    
    if tim(1) == 0
        fprintf('computation canceled.\n');
        cd(actpwd);
        return;
    end
    
    fprintf('ready, time: %2.2f s.\n',tim(2));
    
    data.Dadjust = load('wrap/results.txt');
    cd(actpwd);
    
    yl = [min([0, data.yl(1), min(min(data.Dadjust))]), max(data.yl(2), max(max(data.Dadjust))*1.1)];
    
    axes(AxesZLF);
    for i=1:data.nobd
        fill(data.xbd(i,[1 2 2 1 1]), yl([1 1 2 2 1]), [.9 .9 .9]);
        hold(AxesZLF, 'on');
    end
    plot(AxesZLF,data.x,data.D','color',[.8 .8 .8]);
    plot(AxesZLF,data.x([1 end]),[0 0],'--','color',[.5 .5 .5]);
    
    for i=1:data.nobd
        plot(AxesZLF, data.xbd(i,[1 1]), yl(1:2), 'k', data.xbd(i,[2 2]), yl(1:2), 'k');
    end
    
    plot(AxesZLF,data.x,data.Dadjust','k');
    set(AxesZLF, 'xlim', [min(data.x) max(data.x)], 'ylim', yl);
    xlabel(AxesZLF,'channel');
    hold(AxesZLF, 'off');
    
    set(ZerolineText(7), 'String',sprintf(' data wrapping time: \n %8.2f s', cputime-stime-tim(2)));
    set(ZerolineText(8), 'String',sprintf(' computation time: \n %8.2f s', tim(2)));
    
    onoffButton(Buttons,7,[]);
    
    data.iszla = 1;
    
    set(Empty_Button,'UserData',data);
end
