Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 234

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Errors - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting Started">
<link rel="prev" href="Command-Line-Editing.html#Command-Line-Editing" title="Command Line Editing">
<link rel="next" href="Executable-Octave-Programs.html#Executable-Octave-Programs" title="Executable Octave Programs">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Errors"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Executable-Octave-Programs.html#Executable-Octave-Programs">Executable Octave Programs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Command-Line-Editing.html#Command-Line-Editing">Command Line Editing</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Getting-Started.html#Getting-Started">Getting Started</a>
<hr>
</div>

<h3 class="section">2.5 How Octave Reports Errors</h3>

<p><a name="index-error-messages-176"></a><a name="index-messages_002c-error-177"></a>
Octave reports two kinds of errors for invalid programs.

   <p>A <dfn>parse error</dfn> occurs if Octave cannot understand something you
have typed.  For example, if you misspell a keyword,

<pre class="example">     octave:13&gt; function y = f (x) y = x***2; endfunction
</pre>
   <p class="noindent">Octave will respond immediately with a message like this:

<pre class="example">     parse error:
     
       syntax error
     
     &gt;&gt;&gt; function y = f (x) y = x***2; endfunction
                                   ^
</pre>
   <p class="noindent">For most parse errors, Octave uses a caret (&lsquo;<samp><span class="samp">^</span></samp>&rsquo;) to mark the point
on the line where it was unable to make sense of your input.  In this
case, Octave generated an error message because the keyword for
exponentiation (<code>**</code>) was misspelled.  It marked the error at the
third &lsquo;<samp><span class="samp">*</span></samp>&rsquo; because the code leading up to this was correct but the final
&lsquo;<samp><span class="samp">*</span></samp>&rsquo; was not understood.

   <p>Another class of error message occurs at evaluation time.  These
errors are called <dfn>run-time errors</dfn>, or sometimes
<dfn>evaluation errors</dfn>, because they occur when your program is being
<dfn>run</dfn>, or <dfn>evaluated</dfn>.  For example, if after correcting the
mistake in the previous function definition, you type

<pre class="example">     octave:13&gt; f ()
</pre>
   <p class="noindent">Octave will respond with

<pre class="example">     error: `x' undefined near line 1 column 24
     error: called from:
     error:   f at line 1, column 22
</pre>
   <p class="noindent">This error message has several parts, and gives quite a bit of
information to help you locate the source of the error.  The messages
are generated from the point of the innermost error, and provide a
traceback of enclosing expressions and function calls.

   <p>In the example above, the first line indicates that a variable named
&lsquo;<samp><span class="samp">x</span></samp>&rsquo; was found to be undefined near line 1 and column 24 of some
function or expression.  For errors occurring within functions, lines
are counted from the beginning of the file containing the function
definition.  For errors occurring outside of an enclosing function,
the line number indicates the input line number, which is usually displayed
in the primary prompt string.

   <p>The second and third lines of the error message indicate that the error
occurred within the function <code>f</code>.  If the function <code>f</code> had been
called from within another function, for example, <code>g</code>, the list of
errors would have ended with one more line:

<pre class="example">     error:   g at line 1, column 17
</pre>
   <p>These lists of function calls make it fairly easy to trace the
path your program took before the error occurred, and to correct the
error before trying again.

   </body></html>