function [argout1, argout2, argout3, argout4, argout5, argout6] = getnfws(...
          mode, get_ranges, get_dset, get_vars, get_dset_stride, get_num_urls, ...
          get_georange, get_variables, get_archive, whichurl)
%
% 
% GETstation   Part of the DODS browse package.
%
% This function is used to get hydrography type of data with depth, time and location
% information displayed. Location is primarily used in [-180 180] ranges. [0 360] is
% not acceptable at this moment.
%
% The following variables are required in the archive.m file:
%   TimeRange, LatitudeRange, LongitudeRange, DepthRange, DepthUnits, DodsName, 
%   SelectableVariables, OptionalVariables, Acknowledge
%   ** If the 'OptionalVariables' is not applied in your dataset, NaN is acceptable.
% The following variables are optional in the arvhive.m file:
%   Server, TimeName, LatitudeName, LongitudeName, DepthName, OptionalSelectable, Data_Use_Policy,
%   DataNull, DataScale, DataRange
%
% New features for this function:
%   1. Multi time variables is allowed. Ex., TimeName = str2mat('Year','Month','Day','Time');
%
%   2. 'loaddodsbool' decides if the inventory should be done in this function or in the cat/geturl function.
%      'num_url' decides number of loaddods calls to get data. 
%      Default setting is one, in which 'loaddods' would be called in this function, once for inventory 
%      search, once for getting data.
%      'loaddods' could be set to zero either in Cat_m_File or URL_m_File, if multiple 'loaddods' calls for 
%      inventory search are necessary. In this case, 'num_url' is passed back to this function to decide 
%      how many 'loaddods' calls would be issued subsequently to get data.
%
%   3. 'infotext' is used to display any additional information that data provider needs to returned to
%      users. It would be displayed on the command line following each loaddods call. 
%
%   4. Size of 'DodsName' is not necessary to be the same as 'SelectableVariables', as long as they are 
%      matched for all the common ones . 
%      'DodsName' allows additional information such as StationNo, InstNo, CastNo, returned implicitely
%      as one of the Rxx_, which need not to be appeared in the scrolling list. The additional info are 
%      returned EVERYTIME when an valid data url is issued. 
%
%   5. Added 'OptionalVariables' and 'SelectableOptional' for additional info returned. For example,
%      precision of variable A could be defined as 'OptionalVariables' and needs not to be appeared 
%      in the variable scrolling list. It is coded in geturl function, so that when A is selected, 
%      precision of A is also returned as one of the Rxx_. 
%      'SelectableOptional' is the official name of the 'OptionalVariables', as 'SelectableVariables'
%      to 'DodsName'.
%
%   ** Note that DataNull/DataScale/DataRange has total number of inputs of 'DodsName' + 'OptionalVariables'.
%
%**************************************************************************
%
%

%
% $Log: getnfws.m,v $
% Revision 1.4  2000/03/31 21:02:13  kwoklin
% Add to handle falty loaddods call. Fix string mooring bug.
% Fix tmpwhichvariables bug.
%
% Revision 1.3  2000/03/15 00:38:01  dbyrne
%
%
% Removed all loaddods('-T') calls, as this option is no longer implemented.
% -- dbyrne 00/03/14
%
% Revision 1.2  1999/07/13 14:46:04  kwoklin
% Use getnfws for gbnfws. Fix empty lat/lon return in gbnfwsc. Coded lat/lon
% display in getnfws.   klee
%

% $Id: getnfws.m,v 1.4 2000/03/31 21:02:13 kwoklin Exp $
%Remove multiple longitude/latitude names feature.     klee 07/12/99
%Add longitude transform for browser display back on with some modifications.  klee 07/07/99
%modify from 'getjgsta' for gbnfws lat/lon display     klee 06/06/99
%Enable multi time/lat/lon/depth variables             klee 04/28/99
%Modify to suit hydrography type of data               klee 04/01/99    
%Adopting multiservers                                      10/09/98
%Set up using URL_m_File                                    10/08/98
%Update to adapt new archive.m and browse.m (v. 2.16)       10/07/98    

% used by DODS browser

%global range_day ranges lyr dset var dset_stride num_urls master_georange
%global archive gui_buttons num_vars num_sets

% used only locally
global Pass_Times Pass_Depths old_var old_dset old_ranges 

% explanation:
%
% get_ranges = [WestLon EastLon   -- units: decimal degrees
%           SouthLat NorthLat -- units: decimal degrees
%           MinDepth MaxDepth -- units: meters
%           MinTime  MaxTime]  -- units: decimal years
%
% range_day  = the yearday of [MinTime MaxTime]
%
% lyr  = the length of year of [MinTime MaxTime]
%
% dset = the selected dataset
%
% var = the selected variable
%
% mode may be 'cat' (Catalogue data holdings) or 'get' (Get Data)
%
% if 'get', will have a second arguement, if 0, eval total size of request
% and return. If 1 or greater, get the data.
%

if exist(get_archive) == 2
  eval(get_archive)
else
  dodsmsg(['Problem reading dataset metadata ' get_archive '.m'])
  return
end


if nargin >= 1

  % initialize return arguments
  argout1 = [];
  argout2 = [];
  argout3 = [];
  argout4 = [];
  argout5 = [];
  argout6 = [];

  % SET UP THE METADATA
  % ************************************************************************
  % Set-up for accessing the FRONTS DODS server:
  % Create  constraint expression form browser input values-
  % date, lat/lon, archive type and depth
  % ************************************************************************

  if strcmp(mode,'cat') 		% 'cat' return catalogue of time value
    
    %catch any unmatched data range
    if(get_ranges(4,1) > TimeRange(2) | get_ranges(4,2) < TimeRange(1))
      dodsmsg(' Requested time range does not overlap data. Please respecify')
      return
    end
    
    %save these values
    old_ranges = get_ranges;
    old_dset = get_dset;
    old_var = get_vars;

    %fill up returned arguments with dummy values to prevent crashes
    num_url = 1;  %set default
    loaddodsbool = 1; %set default 
    times = []; Pass_Times = []; depths = []; Pass_Depths = []; 
    lats = []; lons = []; infotext = [];
    url = [];
    
    if strcmp(CatalogServer, 'daily')
      if exist('RefTime') == 0
	RefTime = NaN;
      end
      [times, Pass_Times] = daily(TimeRange, [IntervalTime MidTime ...
	    RefTime], get_ranges);
      if strcmp(get_archive,'reyweek') % should this be implemented for all?
	t = thisday;
	i = find(times < t);
	times = times(i);
	Pass_Times = Pass_Times(i,:);
      end
    elseif strcmp(CatalogServer, 'monthly')
      [times, Pass_Times] = monthly(TimeRange, get_ranges);
    elseif strcmp(CatalogServer, 'annual')
      [times, Pass_Times] = annual(TimeRange, get_ranges);
    elseif exist('Cat_m_File') == 1 % check if 'Cat_m_File' is a local variable
      if exist(Cat_m_File) == 2 % check if Cat_m_File is a script ...
	eval(['[url,loaddodsbool,infotext,times,Pass_Times,',...
	      'depths,Pass_Depths,lats,lons,num_url] = ', ...
	      Cat_m_File, ...
	      '(get_archive, get_ranges, mode);'])
	argout6 = url;
      else
	dodsmsg(['Unable to find script ' Cat_m_File])
	return
      end
    else
      %for datasets that need only one loaddods call for each 
      % inventory and data search
      str = ['[url,loaddodsbool,infotext,times,Pass_Times,', ...
	    'depths,Pass_Depths,lats,lons,num_url]=', ...
	    URL_m_File,'(get_archive, get_ranges, mode);'];
      eval(str);
      argout6 = url;
    end
    
    %get the inventory explicitly
    if loaddodsbool == 1
      loaddods('-F',url);
    end

    % Check for Longitude convention used in the browser, need to convert lon < 0
    % to lon+360 when master_georange(1) == 0
    if num_url > 0
      TempLongitude = [];   namebool = 0;
      if ~isempty(deblank(LongitudeName)) & exist(deblank(LongitudeName)) == 1
        TempLongitude = eval(LongitudeName);  namebool = 1;
      elseif ~isempty(lons)
        TempLongitude = lons;
      end
      if ~isempty(TempLongitude)
        if abs(get_ranges(1,1) - get_ranges(1,2)) >= 360
          % the data were not split into 2 fetch args!
          % don't fiddle with them
        else
          if get_georange(1) == -180
            TempLongitude = (TempLongitude >=180).*(TempLongitude-360)+ ...
		            (TempLongitude < -180).*(TempLongitude+360)+ ...
		            (TempLongitude >= -180 & TempLongitude < 180).*TempLongitude;
          elseif get_georange(1) == 0
            TempLongitude = (TempLongitude >= 360).*(TempLongitude-360)+ ...
		            (TempLongitude < 0).*(TempLongitude+360)+ ...
		            (TempLongitude >= 0 & TempLongitude < 360).*TempLongitude;
          end
          if namebool == 1
            eval([LongitudeName '= TempLongitude; clear TempLongitude'])
          else
            lons = TempLongitude; clear TempLongitude;
          end
        end
      end % end of if ~isempty(TempLongitude)
    end % end of if num_url > 0

    % FIXED so that if there are routines with names in TimeName, they
    % are not accidentally evaluated -- dbyrne 99/06/01
    %argout1, 2, 3, 4, 5, 6 are x, y, z, t, n, URL, respectively
    if isempty(times) & exist(TimeName)==1, argout4 = eval(deblank(TimeName)); 
    elseif ~isempty(times), argout4 = times; else argout4 = []; end
    if isempty(depths) & exist(DepthName)==1, argout3 = eval(deblank(DepthName)); 
    elseif ~isempty(depths), argout3 = depths; else argout3 = []; end
    if isempty(lats) & exist(LatitudeName)==1, argout2 = eval(deblank(LatitudeName));
    elseif ~isempty(lats), argout2 = lats; else argout2 = []; end
    if isempty(lons) & exist(LongitudeName)==1, argout2 = eval(deblank(LongitudeName));
    elseif ~isempty(lons), argout1 = lons; else argout1 = []; end

    % indicate if there really is any data 
    if any(length(argout1) > 0 | length(argout2) > 0 | ...
      length(argout3) > 0 | length(argout4) > 0)
      %argout5 = max(length(argout1),1) * max(length(argout2),1) * ...
      %	  max(length(argout3),1) * max(length(argout4),1);
      %We don't want to loop through it
      if argout4 > 1e-10
        % jg server returns a big negative number if any data is null
        argout5 = num_url;
      else
        argout5 = 0;
      end
    else
      argout5 = 0;
    end

    % Check for Longitude convention used in the browser, need to convert lon < 0
    % to lon+360 when master_georange(1) == 0
    %if argout5 > 0
    %end
    
    % display any extra info related to station/inst/cruiseid
    % work around until character variables are available    klee 03/99
    if exist('infotext') == 1 & ~isempty(infotext)
      % display only during first request
      if whichurl == 1
	dodsmsg(infotext);
      end
    end
      
    return                              % catalog query ('cat') mode over

  else                                  % get data w/o catalog query
    %****************************************************************************
    %Get Data:  Requires multiaccess to server for multiple variables through loops
    % * FRONTS dataset has only one access to the server * 
    %****************************************************************************

    %fill up returned arguments with dummy values to prevent crashes
    %num_url = 1;  loaddodsbool = 1; %set default 
    %times = []; Pass_Times = []; depths = []; Pass_Depths = []; 
    % lats = []; lons = []; infotext = [];
    %url = [];

    %Before going to get, check first if the data ranges has changed, second if the 
    %size of the data reqested is larger than the check_level in browse.m

    if isempty(old_var) | isempty(old_dset) | isempty(old_ranges)
      [x,y,z,t,n,URL] = getnfws('cat',get_ranges, get_dset, get_vars, ...
          get_dset_stride, get_num_urls, get_georange, get_variables, get_archive); 
      get_num_urls = n;
    end
    if size(get_vars) ~= size(old_var) | (get_dset ~= old_dset) | ...
          any(any(get_ranges ~= old_ranges))
      [x,y,z,t,n,URL] = getnfws('cat',get_ranges, get_dset, get_vars, ...
          get_dset_stride, get_num_urls, get_georange, get_variables, get_archive);
      get_num_urls = n;
    end
    %disp('up getdatasize, before get_num_urls');
    %disp(get_num_urls);
    
    if get_num_urls > 0
      %  The browser always sets the longitude range to go from -180 to 180.  Need
      %  to find out how the data set specifies the longitude range: -180 to 180 or
      %  0 to 360 and set up start and end longitudes accordingly. If the range
      %  selected in the browser is between 0 and 180 it does not matter.

      %  add new lat/lon code here
     
      if strcmp(mode, 'datasize')

        %Eval total size of data requested. If larger than check_level, warning is issued.
        %[datasize, nurls]=getxxx('datasize')
	argout2 = get_num_urls;

        % suppose there're avg of 50 pixels in each segment, 10 segments per image, 
        % each pixel has 7 parameters 
        argout1 = (max(length(argout4),1) * 500)*7*8/1e6;

        return
	
      else
 
        %Most The followings are added from getrectg.m.
        %get selected variables and match those to variablelist (DodsName) 
        %and serverlist (Server)
        whichvariables = [];
        for i = 1:size(get_variables,1)
	  for j = 1:size(SelectableVariables,1)
	    if strcmp(deblank(get_variables(i,:)), deblank(SelectableVariables(j,:)))
	      whichvariables = [whichvariables j];
	    end
	  end
        end
        if ~isempty(whichvariables)
	  variablelist = DodsName(whichvariables,:); 
          %The additional DodsName vars than SelectableVariables is taken care here.            klee 03/99
          %set extra to 0 if no addition station/inst/cruiseid/cast info need to be returned from loaddods
          extra = 0;
          nvars = size(SelectableVariables,1);
          nvard = size(DodsName,1);
          if size(DodsName,1) > nvars
            % add stationno/instno/cruiseid/cast to variablelist and increment whichvariables
            extra = extra + (nvard - nvars);
            variablelist = str2mat(variablelist, DodsName(nvars+1:nvard,:));
            whichvariables = [whichvariables nvars+1:nvard];
          end
	  % take into account that there may be mutliple servers
	  if size(Server,1) > 1
	    serverlist = Server(whichvariables,:); 
	  else
	    serverlist = Server; 
	  end
        else
	  dodsmsg('Getnfws: No variables were selected!')
        end


        % construct and evaluate URL(s)
        VERSION = version; VERSION = str2num(VERSION(1));
        tmpvariablelist = []; tmpserverlist = []; tmpvarlist = []; tmpserlist = [];
        year = [];  
        if size(serverlist,1) == 1
          %tmpvariablelist = str2mat(TimeName,LongitudeName,LatitudeName, ...
	  %  DepthName,variablelist);
          tmpvariablelist = str2mat(TimeName,variablelist);
          for i = 1:size(tmpvariablelist,1)
              if abs(tmpvariablelist(i,1)) ~= 32
                  tmpvarlist = [tmpvarlist; tmpvariablelist(i,:)];
              end
          end
	  tmpwhichvariables = [1 2 3 4 whichvariables+4];
          tmpserverlist = str2mat(TimeName,LongitudeName,LatitudeName, ...
	    DepthName, serverlist);
	  % there will be only one URL.  Initialize it.
	  iURL = '';
          % return the URL to be displayed by the browser. D.B. 98/4/5
	  eval([ '[iURL,loaddodsbool,infotext] =', URL_m_File, '(get_archive, get_ranges, mode,', ...
		 'tmpvarlist, serverlist, Pass_Times, Pass_Depths, whichurl);'])
	  if ~isempty(iURL)
	    argout5 = iURL;
	    % because of v4 name length bug and the fact we have no info
	    % about the ORDER of returning variables, we might have to 
	    % evaluate some more URLs here:
	    if VERSION < 5
	      for i = 1:size(variablelist,1)
		s(i) = size(dods_dbk(variablelist(i,:)),2);
	      end
              % move the new loaddods -T here
	      if any(s > 19)
		% loaddods -T is no longer implemented
		% loaddods('-F','-T',iURL);
		loaddods('-F',iURL);
	      else
		loaddods('-F',iURL);
	      end
	    else
	      loaddods('-F',iURL);
	    end % end of version 4 name-bug check
	  end
        end
        if exist('infotext') == 1 & ~isempty(infotext)
	  if whichurl == 1
	    % display only during first request
	    dodsmsg(infotext);
	  end
        end

        % add returned OptionalVariables, if any, to variablelist and increment whichvariables
        % based on the order of OptionalVariables
        % record tag as the final number of whichvariables before adding optional variables
        tag = whichvariables(size(whichvariables,2));
        % and size of whichvariables
        tagatsize = size(whichvariables,2);
        if exist('OptionalVariables') == 1 & ~isnan(OptionalVariables)          
          for i = 1:size(OptionalVariables,1)
            if exist(deblank(OptionalVariables(i,:))) == 1
              % indicate it has been returned to this workspace in loaddods call
              extra = extra + 1;
              variablelist = str2mat(variablelist, OptionalVariables(i,:));
              whichvariables = [whichvariables tag+i];
            end
          end
        end

        % Check for Longitude convention used in browser, need to convert lon < 0
	% to lon+360 when get_georange(1) == 0
        % Adopted from old version of getrectg, here multiple lonname is allowed. klee 07/07/99
        TempLongitude = [];
        if ~isempty(deblank(LongitudeName(1,:)))
          if exist(deblank(LongitudeName(1,:))) == 1
            lonsize = 0;
            lonsize = size(LongitudeName,1);
            str1 = sprintf('%s%s%s','(TempLongitude >=180).*(TempLongitude-360)+', ...
		'(TempLongitude < -180).*(TempLongitude+360)+', ...
	        '(TempLongitude >= -180 & TempLongitude < 180).*TempLongitude');
            str2 = sprintf('%s%s%s','(TempLongitude >= 360).*(TempLongitude-360)+', ...
		'(TempLongitude < 0).*(TempLongitude+360)+', ...
		'(TempLongitude >= 0 & TempLongitude < 360).*TempLongitude');
            if lonsize == 1
              TempLongitude = eval(deblank(LongitudeName));
              if abs(get_ranges(1,1) - get_ranges(1,2)) < 360
                if get_georange(1) == 0
                  eval(['TempLongitude =', str1, ';'])
                elseif get_georange(1) == 0
                  eval(['TempLongitude =', str2, ';'])
                end
              end  
              eval([LongitudeName '= TempLongitude; clear TempLongitude'])
            elseif lonsize > 1
              for i = 1:lonsize
                TempLongitude = eval(deblank(LongitudeName(i,:)));
                if abs(get_ranges(1,1) - get_ranges(1,2)) < 360
                  if get_georange(1) == -180
                    eval(['TempLongitude =', str1, ';'])
                  elseif get_georange(1) == 0
                    eval(['TempLongitude =', str2, ';'])
                  end
                end
                eval([LongitudeName(i,:) '= TempLongitude; clear TempLongitude;'])
              end  % end of for loop
            end  % end of if lonsize == 1, elseif lonsize > 1
          end  % end of exist
        end  % end of ~isempty

        % now make up a list of all returned variables
	% (above list plus time, longitude, latitude, depth),
	% evaluate their sizes, scale them and convert nulls to NaNs.
	% this has to be a temporary variable list -- 'variablelist'
	% is still in use
        tmpwhichvariables = []; tmpsize = []; 
        % make up the latitude and longitude here, borrow Pass_Depths for returned values 
        Longitude = []; Latitude = [];
	tmpvariablelist = str2mat(TimeName,LongitudeName,LatitudeName, ...
	    DepthName, variablelist);  
        count = []; 
        count = find(Pass_Depths(:,3) == year(1));
        Latitude = Pass_Depths(count(1):count(length(count)),1);
        Longitude = Pass_Depths(count(1):count(length(count)),2);
	%tmpwhichvariables = [1 2 3 4 whichvariables+4];
        % if any time/lat/lon/depth has more than one parameter ...
        % for example, TimeName includes year and yearday
        defaultholder = str2mat('TimeName','LongitudeName','LatitudeName','DepthName');
        for i = 1:4
          tmpvname = eval(deblank(defaultholder(i,:)));
          if ~isempty(tmpvname)
            tmpwhichvariables = [tmpwhichvariables, ...
                               reshape((i*ones(size(tmpvname,1),1)),1,size(tmpvname,1))];
          else
            tmpwhichvariables = [tmpwhichvariables, i];
          end
        end
        tmpsize = size(tmpwhichvariables,2);
        tmpwhichvariables = [tmpwhichvariables, whichvariables+4];
	for i = 1:size(tmpvariablelist,1)
	  tmpname = deblank(tmpvariablelist(i,:));
	  if VERSION < 5 % fix v4 bug
	    if size(tmpname,2) > 19
	      tmpname = tmpname(1:19);
	    end
	  end
	  if exist(tmpname) == 1
            tmpout = eval(tmpname);
	    % make a temporary variable to work with
	    sizes(i,:) = size(tmpout);
	    if exist('DataNull') == 1
	      if ~isnan(DataNull(tmpwhichvariables(i)))
		j = find(tmpout == DataNull(tmpwhichvariables(i)));
		tmpout(j) = NaN*j;
	      else
		% do nothing because null values are already NaNs
	      end
	    else
	      % if we have no defined null, do nothing
	      % we used to do this!: (bad, bad)
	      % j = find(tmpout < -1.0e+33);
	      % tmpout(j) = NaN*j;
	    end
	    % stack data in a column and scale it if possible
	    if exist('DataScale') == 1
              %DataScale now contains all the variables that
              %need to be returned   klee 04/01/99
              if ~isnan(OptionalVariables) & size(DataScale,1) ~= size(DodsName,1)+size(OptionalVariables,1)+4
                dodsmsg(['Error is in ' get_archive '.m'])
	      	argout1 = [argout1; tmpout(:)];
              elseif isnan(OptionalVariables) & size(DataScale,1) ~= size(DodsName,1)+4
                dodsmsg(['Error is in ' get_archive '.m'])
	      	argout1 = [argout1; tmpout(:)];
              else
		if ~isnan(DataScale(tmpwhichvariables(i),1))
		  argout1 = [argout1; DataScale(tmpwhichvariables(i),1) + ...
                	  tmpout(:)*DataScale(tmpwhichvariables(i),2)];
	   	else % scale exists but is a nan -- don't scale
		  argout1 = [argout1; tmpout(:)];
	        end
              end
	    else % there is no DataScale
	      argout1 = [argout1; tmpout(:)];
	    end
	  else % the supposedly returned variable DOES NOT EXIST 
	    % in this workspace.  Put in an empty placeholder.
	    if ~isempty(tmpname)
	      eval([tmpname '= [];'])
	    end
	    sizes(i,:) = [0 0];
	  end
	end

	% now convert variablelist to user-friendly names
        % here's the joggling for multi time/lat/lon/depth parameters and added DodsName and OptionalVariables
        defaultnames = str2mat('Time', 'Longitude', 'Latitude', 'Depth');
        tmptimename = eval(defaultholder(1,:));
        if ~isempty(tmptimename)
          if size(tmptimename,1) == 1, names = [defaultnames(1,:)];
          else, names = [upper(tmptimename(1,1)), tmptimename(1,2:length(deblank(tmptimename(1,:))))]; 
                for i = 2:size(tmptimename)
                  names = str2mat(names, [upper(tmptimename(i,1)), ...
			tmptimename(i,2:length(deblank(tmptimename(i,:))))]);
                end
          end
        end
        for i = 2:4
          tmph = eval(defaultholder(i,:));
          if ~isempty(tmph)
            if size(tmph,1) == 1, names = str2mat(names, deblank(defaultnames(i,:)));
            %else, for i = 1:size(tmph,1)
            %        names = str2mat(names, [upper(tmph(i,1)), tmph(i,2:length(deblank(tmph(i,:))))]); 
            %      end
            end
          else 
            names = str2mat(names, '');
          end
        end
        if extra > 0
          nvarw = size(whichvariables,2);
          %names = str2mat(TimeName, 'Longitude', 'Latitude', DepthName);
          for i = 1 : nvarw-extra
            names = str2mat(names, SelectableVariables(whichvariables(i),:));
          end
          if tag > nvars
            %if there is any station/site/cruiseid/inst (help) info needs to be returned
            %tagatsize == number of variables being selected plus help info as above
            %nvars == number of SelectableVariables
            names = str2mat(names, DodsName(nvars+1:size(DodsName),:));
          end
          if exist('OptionalVariables') == 1 & ~isnan(OptionalVariables) 
            if exist('SelectableOptional') == 1 & ~isnan('SelectableOptional')
              %if there is any optional variables associated with selected variables
              whichop = whichvariables(:,tagatsize+1:nvarw);
              if ~isempty(whichop)
                names = str2mat(names, SelectableOptional(whichop(:)-tag,:));
              end
            end
          end
        else
          %names = str2mat(TimeName, LongitudeName, LatitudeName, DepthName, ...
          %  SelectableVariables(whichvariables,:));
          names = str2mat(names, SelectableVariables(whichvariables,:));
        end

        URL = argout5;

        argout2 = sizes;
        argout3 = names;
        argout4 = tmpwhichvariables;
        argout5 = URL;
    %end
	
	return
      end % /* end of strcmp(mode, 'datasize') */
    end % /* end of if num_urls > 0 */
  end % /* end of strcmp(mode, 'cat') */
end % /* end of if nargin >= 1 */















































































