1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
<html lang="en">
<head>
<title>Commands - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Functions-and-Scripts.html#Functions-and-Scripts" title="Functions and Scripts">
<link rel="prev" href="Function-Handles-Inline-Functions-and-Anonymous-Functions.html#Function-Handles-Inline-Functions-and-Anonymous-Functions" title="Function Handles Inline Functions and Anonymous Functions">
<link rel="next" href="Organization-of-Functions.html#Organization-of-Functions" title="Organization of Functions">
<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">
<p>
<a name="Commands"></a>
Next: <a rel="next" accesskey="n" href="Organization-of-Functions.html#Organization-of-Functions">Organization of Functions</a>,
Previous: <a rel="previous" accesskey="p" href="Function-Handles-Inline-Functions-and-Anonymous-Functions.html#Function-Handles-Inline-Functions-and-Anonymous-Functions">Function Handles Inline Functions and Anonymous Functions</a>,
Up: <a rel="up" accesskey="u" href="Functions-and-Scripts.html#Functions-and-Scripts">Functions and Scripts</a>
<hr>
</div>
<h3 class="section">11.10 Commands</h3>
<p>Commands are a special class of functions that only accept string
input arguments. A command can be called as an ordinary function, but
it can also be called without the parentheses like the following example
shows
<pre class="example"> my_command hello world
</pre>
<p class="noindent">which is the same as
<pre class="example"> my_command("hello", "world")
</pre>
<p>The general form of a command call is
<pre class="example"> <var>name</var> <var>arg1</var> <var>arg2</var> ...
</pre>
<p class="noindent">which translates directly to
<pre class="example"> <var>name</var> ("<var>arg1</var>", "<var>arg2</var>", ...)
</pre>
<p>A function can be used as a command if it accepts string input arguments.
To do this, the function must be marked as a command, which can be done
with the <code>mark_as_command</code> command like this
<pre class="example"> mark_as_command name
</pre>
<p class="noindent">where <code>name</code> is the function to be marked as a command.
<p>One difficulty of commands occurs when one of the string input arguments
are stored in a variable. Since Octave can't tell the difference between
a variable name, and an ordinary string, it is not possible to pass a
variable as input to a command. In such a situation a command must be
called as a function.
<!-- ./deprecated/mark_as_command.m -->
<p><a name="doc_002dmark_005fas_005fcommand"></a>
<div class="defun">
— Built-in Function: <b>mark_as_command</b> (<var>name</var>)<var><a name="index-mark_005fas_005fcommand-656"></a></var><br>
<blockquote><p>This function is obsolete and will be removed from a future
version of Octave.
</p></blockquote></div>
<!-- ./deprecated/unmark_command.m -->
<p><a name="doc_002dunmark_005fcommand"></a>
<div class="defun">
— Built-in Function: <b>unmark_command</b> (<var>name</var>)<var><a name="index-unmark_005fcommand-657"></a></var><br>
<blockquote><p>This function is obsolete and will be removed from a future
version of Octave.
</p></blockquote></div>
<!-- ./deprecated/iscommand.m -->
<p><a name="doc_002discommand"></a>
<div class="defun">
— Built-in Function: <b>iscommand</b> (<var>name</var>)<var><a name="index-iscommand-658"></a></var><br>
<blockquote><p>This function is obsolete and will be removed from a future
version of Octave.
</p></blockquote></div>
<!-- ./deprecated/mark_as_rawcommand.m -->
<p><a name="doc_002dmark_005fas_005frawcommand"></a>
<div class="defun">
— Built-in Function: <b>mark_as_rawcommand</b> (<var>name</var>)<var><a name="index-mark_005fas_005frawcommand-659"></a></var><br>
<blockquote><p>This function is obsolete and will be removed from a future
version of Octave.
</p></blockquote></div>
<!-- ./deprecated/unmark_rawcommand.m -->
<p><a name="doc_002dunmark_005frawcommand"></a>
<div class="defun">
— Built-in Function: <b>unmark_rawcommand</b> (<var>name</var>)<var><a name="index-unmark_005frawcommand-660"></a></var><br>
<blockquote><p>This function is obsolete and will be removed from a future
version of Octave.
</p></blockquote></div>
<!-- ./deprecated/israwcommand.m -->
<p><a name="doc_002disrawcommand"></a>
<div class="defun">
— Built-in Function: <b>israwcommand</b> (<var>name</var>)<var><a name="index-israwcommand-661"></a></var><br>
<blockquote><p>This function is obsolete and will be removed from a future
version of Octave.
</p></blockquote></div>
</body></html>
|