function range = selectSonarRange(sonarStr)
%function range = selectSonarRange(sonarStr)
%	sonarStr: 'select' - check: currentRange; mission{1}.sonarrange; else open input box
%		  'clear'  - set currentRange, rnage = [];
	global currentRange, global mission

if nargin == 0,
	if isempty(currentRange),
		range = selectSonarRange('select');
	else 
		range = currentRange;
	end
	return
end

if strcmp(sonarStr,'select'),
	if ~isfield(mission{1},'sonarrange'),
		prompt{1} = 'Sonar Range (meters)';
		defans{1} = '100';
		
		answer = inputdlg(prompt{1},'Enter sonar range',1,defans);
		if isempty(answer),
			range = selectSonarRange('select');
			return
		end
		range = str2num(answer{1});
	else
		range = mission{1}.sonarrange;
	end
elseif strcmp(sonarStr,'clear'),
	currentRange = [];
	range = [];
end

currentRange = range;
