function mcs_gui_load
%
% Loads a saved MCS box information file and restores values.
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
mcs_global
%
% 'Check if _gui.mat file exists:'
gui_file=[MCS.mcs_root,'_mcs.mat'];
if exist(gui_file,'file')~=2, 
	disp(['Could not find file ',gui_file,' to load']); return;
end
% 'Load parameters from _gui.mat file:'
MCS_cur=MCS; mcs_root=MCS.mcs_root;
str=['load ',gui_file]; eval(str);
lmc=length(MCS.mc_parms); if lmc<15, MCS.mc_parms=[MCS.mc_parms, zeros(1,15-lmc)]; end
%
% Transfer all loaded fields (except swami_cal_opts, which may change) to MCS_cur:
MCS_cur=structure_copy2(MCS_cur,MCS,{'swami_cal_opts'});
%loaded_fields=fieldnames(MCS);
%for j=1:length(loaded_fields),
%	expr=['MCS_cur.',loaded_fields{j},'=MCS.',loaded_fields{j},';'];
%	eval(expr),
%end
% Replace MCS by MCS_cur:
MCS=MCS_cur; MCS.mcs_root=mcs_root; clear MCS_cur;
% Set any new fields that old MCS might not have:
if ~isfield(MCS.TAPE,'file_header_bytes'), MCS.TAPE.file_header_bytes=0; end
if ~isfield(MCS.TAPE,'file_footer_bytes'), MCS.TAPE.file_footer_bytes=0; end
%
% Reset directory symbol:
if isunix, MCS.dx='/'; elseif isppc, MCS.dx=':'; else, MCS.dx='\'; end
% Fill MCS boxes with new values:
Gtags=get(MBOX.handle(1,1:MBOX.nboxtot),'Tag');
% Skip box # 1 since that has programs listed, which may be added to:
tags_no_update={'Program','SWAMI calfac'};
ntags=length(HBOX.tag); ii_tags_update=ones(1,ntags);
for jbox=1:length(tags_no_update),
	ii_no_update=find(strcmp(HBOX.tag,tags_no_update{jbox}));
    ii_tags_update(ii_no_update)=0;
end
ii_tags=find(ii_tags_update); ntag_update=length(ii_tags);
for jtag=1:ntag_update,
    jbox_H=ii_tags(jtag);
% Find HBOX tag that is same as MBOX tag:
	ii=find(strcmp(HBOX.tag{jbox_H},Gtags));
	if ~isempty(ii),
		jbox_G=ii(1);
		if jbox_G<=HBOX.nboxtot,
			h1=MBOX.handle(1,jbox_G);
%             if strcmp(HBOX.tag{jbox_H},'re-init'), keyboard; end
			if ~strcmp(HBOX.tag{jbox_H},'SWAMI calfac'), set(h1,'String',HBOX.string{jbox_H}); else, 'FOUND CALFAC', end
% 			set(h1,'String',HBOX.value(jbox_H));
			set(h1,'String',HBOX.string{jbox_H});
			set(h1,'Value',HBOX.value(jbox_H));
			set(h1,'Tag',HBOX.tag{jbox_H});
		end
	else
%%		'Did not find Tag'
	end
end
%
h1=findobj(MBOX.figno,'Tag','Program');
val=find(MBOX.prog_order==MCS.iiprog); if isempty(val), val=1; end
%%val,
set(h1,'Value',val);
mcs_act('Program');
%
