function [URL] = usgstsu(archive, urlinfolist, urlinfotext, StartColumn, ...
                            EndColumn, StartRow, EndRow, dset_stride, ...
                            ranges, variablelist, server, whichurl)
%
% This function will build the USGSTS file name and variable index.
%

% The preceding empty line is important.
%
% $Log$

% $Id$
% klee 08/17/99

Constraint = [];
if exist(archive) == 2
  eval(archive)
else
  dodsmsg('Metadata not found!')
  return
end

filename = urlinfotext(:,:);
stimes = urlinfolist(:,6);
etimes = urlinfolist(:,7);
varindex = urlinfolist(:,8:size(urlinfolist,2));

fsize = size(filename,1);
varsize = size(variablelist,1);
%Constraint = ['''-k''',','''];
for i = 1:fsize
  varlist = [];
  for j = 1:varsize 
    % If any of the selectable variables belongs to the varindex also
    if any(varindex(i,:) == j)
      tmpvar = deblank(variablelist(j,:));
      if isempty(varlist)
        varlist = [varlist, tmpvar, '[', num2str(stimes(i)), ':', num2str(etimes(i)), ']',...
                   '[0][0][0]'];
      else
        varlist = [varlist, ',', tmpvar, '[', num2str(stimes(i)), ':', num2str(etimes(i)), ...
                   '][0][0][0]'];
      end
      %if j < varsize
      %  varlist = [varlist, ','];
      %end
    end
  end
  varlist = [varlist, ',time2[', num2str(stimes(i)), ':', num2str(etimes(i)), ']'];
  Constraint = [Constraint, Server, deblank(filename(i,:)), '?', varlist];
  if i < fsize
    Constraint = [Constraint, ' '];
  end
end
%Constraint = [Constraint, ''''];

URL = Constraint;
return
