%
% function expression = iif( expression_to_test, expression_true[, expression_false] )
%
%          tests an expression and returns the true_expression or the false
%          expression accordingly
%

%
% Copyright (C) Sept-2001 George P. Pavlidis, gpavlis@ceti.gr
%
function expression = iif( varargin );

	switch nargin,
	case 0,
		syntax( upper(mfilename), 'Syntax Error: at least one parameter was expected.' );
		return;
	case 1,
		expression_to_test=varargin{1};
		expression_true=1; 
		expression_false=0;
	case 2,
		expression_to_test=varargin{1};
		expression_true=varargin{2}; 
		expression_false=[];
	case 3,
		expression_to_test=varargin{1};
		expression_true=varargin{2}; 
		expression_false=varargin{3};
	end;

	if expression_to_test, 
		expression = expression_true;
	else
		expression = expression_false;
	end;
	
return;