image thumbnail

ehelp: a pedestrian extended help extractor utility

by

 

27 Jan 2006 (Updated )

ehelp typically is used as a subroutine to extract extended help from its main function

r=afun(varargin)
% AFUN
%	computes the sum of two scalars
%
% SYNTAX
%	help
%		afun		to show this screen
%		help afun	to show this screen
%		afun -h1	to show extended help about ML
%		afun -h2	to show extended help about TMW
%	runtime
%		R=afun S1 S2
%		R=afun(S1,S2)
%
% S1	:	first  scalar
% S2	:	second scalar
% R	:	result of S1+S2

%--------------------------------------------------------------------------------
function	r=afun(varargin)
		r=[];
	if	~nargin
		help(mfilename);
		return;
	end
	if	nargin == 1	&&...
		ischar(varargin{1})
	switch	varargin{1}
	case	'-h1'
		disp(ehelp(mfilename,'__H1__','%+'));	% extract __H1__ section
	case	'-h2'
		disp(ehelp(mfilename,'__H2__','%'));	% extract __H2__ section
	end
		return;
	end
		r=sum([varargin{:}]);
		return;
%--------------------------------------------------------------------------------
% !!!EHELP is copy/pasted HERE!!! (not shown for sake of brevity
%--------------------------------------------------------------------------------
%+__H1__
%+MATLAB is a high-level language and interactive
%+environment that enables
%+you to perform computationally intensive tasks
%+faster than with traditional programming languages
%+such as C, C++, and Fortran.
%+
%+see http://www.mathworks.com for informations
%+__H1__
%__H2__
%The MathWorks
%	Accelerating the pace of engineering and science
%__H2__
%--------------------------------------------------------------------------------

Contact us