q = input('Is there an options file for this dataset? (y/n) [y] >> ','s');
  if isempty(q)
    q = 'y';
  end
  if isstrcmp(lower(deblank(q)),'y')
    opts_file = input('Options file ([CR] to abort) >> ','s');
    if isempty(opts_file)
      return
    else
      if isstr(opts_file)
	if exist(opts_file) == 2
	  opts_file = deblank(opts_file);
	  opts_file = fliplr(deblank(fliplr(opts_file)));
	  oldproplist = proplist;
	  oo = size(oldproplist);
	  for i = 1:oo(1);
	    eval([oldproplist(i,:) '= [];'])
	  end
	  eval(opts_file)
	  kids = get(0,'children');
	  for i = 1:length(kids) 	% close all subsidiary staplot plots
	    if isstrcmp(get(kids(i),'userdata'),'staplot')
	      close(kids(i))
	    end
	  end
	  F_HANDLES = []; figchars = [];
	  set(B_HANDLES(4),'String', proplist)
	  set(B_HANDLES(12),'String', '')
	  if ~isempty(sections)
	    s = size(sections);
	    buttonstring = ['Sel All'];
	    for i = 1:s(1)
	      newstring = ['section ' num2str(i)];
	      buttonstring = str2mat(buttonstring, newstring);
	    end
	  end
	  set(B_HANDLES(3),'Style','Popup', 'String', ...
	      buttonstring)
	  drawnow
	  label = str2mat('Worldmap',batlist);
	  set(B_HANDLES(7),'Style','Popup','String',label)
	  drawnow
	  argin = ['options_file:' opts_file];
	  hydroplt(argin,oldproplist)
	  % and we're outta here
	else
	  disp([opts_file ' does not appear to be a valid options file.'])
	  disp('please check your matlabpath')
	  return
	end
      else
	disp('not a valid filename')
	return
      end
    end
  else
    file = input('Data file name ([CR] to abort) >> ',  's');
    sss = sprintf('\n'); disp(sss)
    if isempty(file)
      return
    else
      if ~isstr(file)
	disp('Not a valid data file name')
	return
      else
	l = length(file);
	if l > 4,
	  if strcmp(file(l-3:l),'.mat')
	    arg = file;
	  else
	    arg = [file '.mat'];
	  end
	else
	  arg = [file '.mat'];
	end
	if(exist(arg) ~= 2),
	  disp('Data file name or path specification incorrect. Please try again.')
	  return
	else 				% data file looks ok at first glance
	  % clear the proplist values
	  s = size(proplist);
	  for i = 1:s(1)
	    eval([proplist(i,:) '= [];'])
	  end
	  ofile = file;
	  opts_file = 'gvars';
	  disp('Loading default options ...')
	  sss = sprintf('\n'); disp(sss)
	  eval(opts_file) 		% loading default options
	  file = ofile;
	  s = size(proplist); sss = []; for i = 1:s(1); sss = [sss ' ']; end
	  sss = sprintf(' %s',[proplist sss']');
	  eval(['global ' sss]);
	
	  % only now can we load, when the standard vars are global
	  disp(['loading ' file])
	  % take care of weird filenames
	  while (~isempty(findstr(file,'''')))
	    file = strrep(file,'''','');
	  end
	  arg = ['load ' '''' file '''']; 
	  eval(arg); 
	  sss = sprintf('\n'); disp(sss)
	  disp('If there are any variables in your new data file that were')
	  disp('not present in the old one (or in the default), type')
	  disp('''global [variable_name]'' to access them in the main workspace.')
	  
	  if ~isempty(eval(lon_var)) 	% the single check for standard data
	    s = size(eval(lon_var));
	    if any(s == 1) & any(s > 1)
	      nstn = max(s);
	    end
	    station_style = 12*ones(1,nstn);
	    sections = [1 nstn];
	  
	    s = size(proplist); s = s(1); k = zeros(s(1),1);
	    for i = 1:s(1);
	      if ~isempty(eval(proplist(i,:))),
		k(i) = 1;
	      else
		if strcmp(deblank(proplist(i,:)),'Dist')
		  k(i) = 1;
		else
		  eval(['clear global ' proplist(i,:)])
		end
	      end
	    end
	    k = find(k); proplist = proplist(k,:); typevar = typevar(k);
	  
	  else % GO TO NONSTANDARD MENU: GET RID OF STANDARD VARS FIRST
	    s = size(proplist);
	    for i = 1:s(1)
	      if ~isempty(deblank(proplist(i,:)))
		if ~strcmp(deblank(proplist(i,:)),'Dist')
		  eval(['clear global ' proplist(i,:)])
		end
	      end
	    end
	    typevar = [];
	    sss = sprintf('\n'); disp(sss)
	    
	    % construct a new proplist
	    arg = ['str2mat(''Dist''']; % dist is just a place-keeper here
	    disp('Your data is not in the default STAPLOT format.')
	    nstn = input('How many stations do you have? >> ');
	    
	    sumvar = 1;
	    lon_var = input('What variable contains Longitude? >> ','s');
	    if ~isempty(lon_var), 
	      arg = [arg ',lon_var']; 
	      sumvar = sumvar + 1;
	    else
	      lon_var = 'Lon';
	    end
	    eval(['global ' lon_var]);
	    
	    lat_var = input('Latitude? >> ','s');
	    if ~isempty(lat_var), 
	      arg = [arg,',lat_var']; 
	      sumvar = sumvar + 1;
	    else
	      lat_var = 'Lat';
	    end
	    eval(['global ' lat_var]);
	    
	    sta_var = input('Station number? >> ','s');
	    if ~isempty(sta_var), 
	      arg = [arg ',sta_var'];
	      sumvar = sumvar + 1;
	    else
	      sta_var = 'Sta_no';
	    end
	    
	    pr_var = input('Pressure? >> ','s');
	    if ~isempty(pr_var), 
	      arg = [arg ',pr_var'];
	      sumvar = sumvar + 1;
	      pr_type = input('What kind of variable (type 2 or 3) is it? [3] >> ');
	      if isempty(pr_type)
		pr_type = 3;
	      end
	    else
	      pr_var = 'PR';
	    end
	    
	    de_var = input('Depth? >> ','s');
	    if ~isempty(de_var), 
	      arg = [arg ',de_var'];
	      sumvar = sumvar + 1;
	      de_type = input('What kind of variable (type 2 or 3) is it? [3] >> ');
	      if isempty(de_type)
		de_type = 3;
	      end
	    else
	      de_var = 'DE';
	    end
	    
	    pt_var = input('Potential Temperature? >> ','s');
	    if ~isempty(pt_var), 
	      arg = [arg ',pt_var'];
	      sumvar = sumvar + 1;
	    else
	      pt_var = 'PT';
	    end
	  
	    te_var = input('In situ temperature? >> ','s');
	    if ~isempty(te_var), 
	      arg = [arg ',te_var'];
	      sumvar = sumvar + 1;
	    else
	      te_var = 'TE';
	    end
	  
	    sa_var = input('Salinity? >> ','s');
	    if ~isempty(sa_var), 
	      arg = [arg ',sa_var'];
	      sumvar = sumvar + 1;
	    else
	      sa_var = 'SA';
	    end
	    
	    str = input('Other? [CR to abort] >> ','s');
	    stortype = [];
	    while ~isempty(str), 
	      typ = input('Is this a type 1, type 2 or type 3 variable? >> ');
	      stortype = [stortype typ];
	      arg = [arg ',' '''' str ''''];
	      str = input('Other? [CR to abort] >> ','s');
	    end
	    disp('You can add more variables by using the ''Add Prop'' button')
	    
	    arg = sprintf('%s',['proplist = '  arg ');']);
	    eval(arg)
	    len = size(proplist); len = len(1); 
	    typevar = zeros(1,len); typevar(1) = 1;
	    l = length(stortype);
	    typevar(sumvar+1:sumvar+l) = stortype;
	    s = size(proplist); str = []; for i = 1:s(1); str = [str ' ']; end
	    str = sprintf('%s',[proplist str']'); eval(['global ' str]); 
	    arg = ['load ' '''' file '''']; 
	    eval(arg); 
	    
	    % try to set types for all the variables in the proplist
	    for i = 1:length(proplist);
	      if (strcmp(deblank(proplist(i,:)),lon_var) | ...
		    strcmp(deblank(proplist(i,:)),lat_var) | ...
		    strcmp(deblank(proplist(i,:)),sta_var) | ...
		    strcmp(deblank(proplist(i,:)),'Dist'))
		typevar(i) = 1;
	      elseif (strcmp(deblank(proplist(i,:)),te_var) | ...
		    strcmp(deblank(proplist(i,:)),pt_var) | ...
		    strcmp(deblank(proplist(i,:)),sa_var))
		typevar(i) = 3;
	      elseif strcmp(deblank(proplist(i,:)),pr_var)
		typevar(i) = pr_type;
	      elseif strcmp(deblank(proplist(i,:)),de_var)
		typevar(i) = de_type;
	      end
	    end
	    
	    if ~isempty(nstn) 		% one chance
	      station_style = 12*ones(1,nstn);
	      sections = [1 nstn];
	    elseif ~isempty(lon_var) 	% a second chance
	      nstn = length(eval([lon_var '(:)']));
	      station_style = 12*ones(1,nstn);
	      sections = [1 nstn];
	    else
	      sss = sprintf('\n'); disp(sss)
	      disp('Please examine the variables and variable names in the default')
	      disp('options files, ''gvars.m'' and ''gvarso.m''. You won''t')
	      disp('be able to do very much (e.g. plot anything) until you have at')
	      disp('least some of these variables determined.  You can copy these')
	      disp('file into a new ones, change them to suit you, and load again,')
	      disp('to have a much greater chance of success here. Particularly')
	      disp('crucial are the number of stations, nstn, the data file names,')
	      disp('and the ''typevar'' argument, which can be examined with')
	      disp('''showtype'' and set with ''settype''.')
	      sss = sprintf('\n'); disp(sss)
	    end
	    
	    sss = sprintf('\n'); disp(sss)
	    disp('To add additional variables to the defaults now on the menu,')
	    disp('type ''global [variable_name]'' in the main workspace, LOAD the')
	    disp('datafile there, and then use the ''Add Prop'' button.')
	    sss = sprintf('\n'); disp(sss)
	  end
	  
	  % ok, the gvars had the standard proplist, and in the 
	  % nonstandard menu, we entered them.  Time to make them work.
	  s = size(proplist); sss = []; for i = 1:s(1); sss = [sss ' ']; end
	  sss = sprintf('%s',[proplist sss']');
	  eval(['global ' sss]);
	  
	  kids = get(0,'children');
	  for i = 1:length(kids) 	% close all subsidiary staplot plots
	    if isstrcmp(get(kids(i),'userdata'),'staplot')
	      close(kids(i))
	    end
	  end
	  F_HANDLES = []; figchars = [];
	  if ~isempty(sections)
	    s = size(sections);
	    buttonstring = ['Sel All'];
	    for i = 1:s(1)
	      newstring = ['section ' num2str(i)];
	      buttonstring = str2mat(buttonstring, newstring);
	    end
	  end
	  set(B_HANDLES(3),'Style','Popup', 'String', ...
	      buttonstring)
	  drawnow
	  prop = [0 0 0]; Dist = []; sta = [];
	  set(B_HANDLES(4),'String', proplist)
	  set(B_HANDLES(12),'String', '')
	  if ~isempty(eval(lon_var)) & ~isempty(eval(lat_var))
	    hydroplt('replot')
	  end
	end 				% end of 'data file exists'
      end
    end
  end
end
