%Copyright (c) 2010, Luuk J.G.W. van Wilderen
%
%load_data.m

function load_data

global filename
%Although defined in globfit_bio_gui, opt_specs needs to be deleted from
%memory. Otherwise it is possible that the 'save figures and data' button
%(save_figs_data) saves data from a previous fit on a different dataset.
global opt_specs
opt_specs=[];

[FileName,PathName] = uigetfile('*.dat;*.dsa','Select data');

if eq(FileName,0)==1
    error('No data file loaded');   %Error message needed, to prevent figure being created by plot_raw_data
end
    
filename=strcat(PathName,FileName);

if length(filename)<97
    set(findobj('Tag','load_data_text'),'Visible','on','String',['    Datafile file: ' filename]);
elseif length(filename)>96
    set(findobj('Tag','load_data_text'),'Visible','on','String',['    Datafile file: ' filename(end-96:end)]);
end

plot_raw_data