octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how can I display the doc message from a command?


From: Andrea Latina
Subject: Re: how can I display the doc message from a command?
Date: Wed, 13 Sep 2006 17:41:50 +0200

Well, this print_usage() function seems to be exactly what I was
looking for. You are right, printing a short help message makes much
more sense than printing a page full of text.
I've already modified my code to use it.
Thank you very much again,
Andrea

P.S. Yes, I'm consulting www.octave.org very often in the last times.
That page is an irreplaceable and precious source of information,
indeed. Nevertheless I could not find anything like, for example, the
GSL on-line manual:

(see http://www.gnu.org/software/gsl/manual/html_node/ )

where all its functions are catalogued and documented.

A couple of days ago, for instance, I had an hard time to find the
octave internal random number generator and how it works.  After a
while I finally found 'liboctave/oct-rand.h' with 'class octave_rand'
and its static members and everything went fine, but the point is:
Searching for what I need into the code it is not difficult but I
wonder how many useful and powerful functions exist, of which I don't
even know the existence...

Anyway, many thanks again. Cheers,
Andrea

On 13/09/06, John W. Eaton <address@hidden> wrote:
On 13-Sep-2006, Andrea Latina wrote:

| > from a command defined by
| >
| > DEFUN_DLD or DEFUN (or DEFCMD, ..)
| >
| > how can I display its own doc message?
|
| Finally I've done like this:
|
|   if (args.length()==0)
|     feval("help", octave_value("CommandName"), 0);
|
| is this the best way or I can avoid to call feval??

Are you sure you really want the full help text?  Comments from users
have shown that most are confused when a usage error results in the
full help text appearing, especially when the help text comes from
some incorrect code that is buried deep inside some large program.

The recommended way to handle usage messages is with the print_usage
function:

  if (args.length () == 0)
    print_usage ();

If the doc string uses Texinfo markup, this will extract just the
@deftypefn or @defcmd lines from the doc string and display them in a
nicely formatted way.  For example:

  octave:1> svd

  Invalid call to svd.  Correct usage is:

   -- Loadable Function: S = svd (A)
   -- Loadable Function: [U, S, V] = svd (A)


  Additional help for built-in functions and operators is
  available in the on-line version of the manual.  Use the command
  `doc <topic>' to search the manual index.

  Help and information about Octave is also available on the WWW
  at http://www.octave.org and via the address@hidden
  mailing list.


jwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]