function icnv = staticnv(str, varargin)
% ------------------------------------------------------------------
% Return a vector to the indexes of variables that need to be 
% converted before statistical updates, or after statistical
% calculation.
%
% SYNOPSIS:
%
%   icnv = statcnv(what)
%   icnv = statcnv(what, where)
%
% PARAMETERS:
%
%   what
%      What kind of conversion to look for. These are found from
%      from keywords in the variables names. Possible values are:
%
%         '-hdg' : for heading conversion
%
%   where
%      Column vector of indexes in current context. For example, 
%      if variable `5' needs conversion, but is located at index 
%      `3' in current context, then `where(3)' should be `5'.
%      This vector should have the same length as the number of
%      variables in current context.
%
% RETURN:
%
%   icnv
%      Column vector of indexes to be converted for this conversion
%      type. 
%
% ------------------------------------------------------------------
%Time:<Last updated on 98/07/03 at 20:04:42 by jaccard@pc34.gfi.uib.no>
%File:</home1/jaccard/data1/codas3/gfi/matlab/matlab50/scan/staticnv.m>

scanglob;

% Defaults:
ivar = 1:NVARS;

l = nargin - 1;
if l > 0,
  ivar = varargin{1};
end

if length(str) == 0,
  icnv = [];
else
  switch str
	 case '-hdg',
		str = '[HDG]';
	 otherwise,
		error('Unknown conversion type');
  end
end

% Flag all data to be converted:
l = length(ivar);
icnv = zeros(1,l);
for i=1:l,
  j = ivar(i);
  if findstr(VARNAMES(j,:), str) > 0,
	 icnv(i) = 1;
  end
end

% Build the index array:
icnv = find(icnv);

return;
