function buttonviewlogfile(hObject, eventdata, parentfig, Empty_Button, basichi, basicfsz, sty)
data = get(Empty_Button,'UserData');

if (isfield(data, 'isafs') == 0) || (data.isafs == 0)
    return
end

actpwd = pwd;
cd(data.calcp);

fidlog = fopen('wrap/AFScomputation.log');

txt = [];
TXT = [];
i = 1;
while 1
    txtline = fgetl(fidlog);
    if ~ischar(txtline)
        break;
    end
    txt{i} = txtline;
    if (i == 1) || (i == 5)
        TXT = [TXT, txt{i}, txt{i}, '\n'];
    elseif i < 5
        TXT = [TXT, txt{i}(1), txt{i}, txt{i}(end), '\n'];
    elseif strcmp('%',txt{i}(1))
        TXT = [TXT, txt{i}(1), txt{i}, '\n'];
    else
        TXT = [TXT, txt{i}, '\n'];
    end
    i = i+1;
end

fig = figure;
pause(.1);

scrsz = get(0,'ScreenSize');

set(fig,'Position',[100, scrsz(4)*1/5, min(scrsz(3)-100, 1500), min(scrsz(4)*4/5, 800)]);
pause(.1);

set(fig,'Name','View log file for AFS computation','NumberTitle','off','MenuBar','none','Toolbar','none','color','white');

Textfield = uicontrol('Style','edit','String',sprintf(TXT),'HorizontalAlignment','left','Fontsize',11,'BackgroundColor','white',...
    'Units','normalized','FontName','courier 10 pitch','Position',[0, 0, 1, 1],'Max',2);


function innerbuttoncancel(hobject, eventdata, parentfig)
close(parentfig);
