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

edem
edem
% EHELP
% a pedestrian extended help extractor utility
 
% assume we created a simple function AFUN.M
% to see what we did, click here
 
% let's look at the various help levels
 
% 1) classical help
      help afun;
 
  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
 
% 2) extended help
      afun -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
 
      afun -h2;
 
The MathWorks
      Accelerating the pace of engineering and science
 
% display contents of AFUN
      type afun.m
 
% 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