Mercurial > hg > octave-nkf
annotate doc/interpreter/basics.txi @ 10843:229675bb7647 ss-3-3-52
version is now 3.3.52
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 01 Aug 2010 11:49:45 -0400 |
parents | 322f43e0e170 |
children | a4f482e66b65 |
rev | line source |
---|---|
7018 | 1 @c Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2005, 2006, |
8920 | 2 @c 2007, 2008, 2009 John W. Eaton |
7018 | 3 @c |
4 @c This file is part of Octave. | |
5 @c | |
6 @c Octave is free software; you can redistribute it and/or modify it | |
7 @c under the terms of the GNU General Public License as published by the | |
8 @c Free Software Foundation; either version 3 of the License, or (at | |
9 @c your option) any later version. | |
10 @c | |
11 @c Octave is distributed in the hope that it will be useful, but WITHOUT | |
12 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 @c for more details. | |
15 @c | |
16 @c You should have received a copy of the GNU General Public License | |
17 @c along with Octave; see the file COPYING. If not, see | |
18 @c <http://www.gnu.org/licenses/>. | |
3294 | 19 |
4167 | 20 @node Getting Started |
3294 | 21 @chapter Getting Started |
22 | |
23 This chapter explains some of Octave's basic features, including how to | |
24 start an Octave session, get help at the command prompt, edit the | |
25 command line, and write Octave programs that can be executed as commands | |
26 from your shell. | |
27 | |
28 @menu | |
6620 | 29 * Invoking Octave from the Command Line:: |
3294 | 30 * Quitting Octave:: |
31 * Getting Help:: | |
32 * Command Line Editing:: | |
33 * Errors:: | |
34 * Executable Octave Programs:: | |
35 * Comments:: | |
36 @end menu | |
37 | |
6620 | 38 @node Invoking Octave from the Command Line |
39 @section Invoking Octave from the Command Line | |
3294 | 40 |
41 Normally, Octave is used interactively by running the program | |
42 @samp{octave} without any arguments. Once started, Octave reads | |
43 commands from the terminal until you tell it to exit. | |
44 | |
45 You can also specify the name of a file on the command line, and Octave | |
46 will read and execute the commands from the named file and then exit | |
47 when it is finished. | |
48 | |
49 You can further control how Octave starts by using the command-line | |
50 options described in the next section, and Octave itself can remind you | |
51 of the options available. Type @samp{octave --help} to display all | |
52 available options and briefly describe their use (@samp{octave -h} is a | |
53 shorter equivalent). | |
54 | |
55 @menu | |
56 * Command Line Options:: | |
57 * Startup Files:: | |
58 @end menu | |
59 | |
4167 | 60 @node Command Line Options |
3294 | 61 @subsection Command Line Options |
62 @cindex Octave command options | |
63 @cindex command options | |
64 @cindex options, Octave command | |
65 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
66 Here is a complete list of the command line options that Octave |
3294 | 67 accepts. |
68 | |
6620 | 69 |
3294 | 70 @table @code |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
71 @item --debug |
3294 | 72 @itemx -d |
73 @cindex @code{--debug} | |
74 @cindex @code{-d} | |
75 Enter parser debugging mode. Using this option will cause Octave's | |
76 parser to print a lot of information about the commands it reads, and is | |
77 probably only useful if you are actually trying to debug the parser. | |
78 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
79 @item --doc-cache-file @var{filename} |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
80 @cindex @code{--doc-cache-file @var{filename}} |
8923
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
81 Specify the name of the doc cache file to use. The value of @var{filename} |
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
82 specified on the command line will override any value of |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
83 @w{@env{OCTAVE_DOC_CACHE_FILE}} found in the environment, but not any commands |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
84 in the system or user startup files that use the @code{doc_cache_file} |
8923
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
85 function. |
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
86 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
87 @item --echo-commands |
3294 | 88 @itemx -x |
89 @cindex @code{--echo-commands} | |
90 @cindex @code{-x} | |
91 Echo commands as they are executed. | |
92 | |
5190 | 93 @item --eval @var{code} |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
94 Evaluate @var{code} and exit when finished unless @option{--persist} is also |
5190 | 95 specified. |
96 | |
3294 | 97 @item --exec-path @var{path} |
98 @cindex @code{--exec-path @var{path}} | |
99 Specify the path to search for programs to run. The value of @var{path} | |
100 specified on the command line will override any value of | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
101 @w{@env{OCTAVE_EXEC_PATH}} found in the environment, but not any commands |
3294 | 102 in the system or user startup files that set the built-in variable |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
103 @w{@env{EXEC_PATH}}. |
3294 | 104 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
105 @item --help |
3294 | 106 @itemx -h |
107 @itemx -? | |
108 @cindex @code{--help} | |
109 @cindex @code{-h} | |
110 @cindex @code{-?} | |
111 Print short help message and exit. | |
112 | |
6620 | 113 @item --image-path @var{path} |
114 @cindex @code{--image-path @var{path}} | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
115 Add path to the head of the search path for images. The value of |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
116 @var{path} specified on the command line will override any value of |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
117 @w{@env{OCTAVE_IMAGE_PATH}} found in the environment, but not any commands |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
118 in the system or user startup files that set the built-in variable |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
119 @w{@env{IMAGE_PATH}}. |
6620 | 120 |
3294 | 121 @item --info-file @var{filename} |
122 @cindex @code{--info-file @var{filename}} | |
123 Specify the name of the info file to use. The value of @var{filename} | |
124 specified on the command line will override any value of | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
125 @w{@env{OCTAVE_INFO_FILE}} found in the environment, but not any commands |
6653 | 126 in the system or user startup files that use the @code{info_file} |
6477 | 127 function. |
3294 | 128 |
129 @item --info-program @var{program} | |
130 @cindex @code{--info-program @var{program}} | |
131 Specify the name of the info program to use. The value of @var{program} | |
132 specified on the command line will override any value of | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
133 @w{@env{OCTAVE_INFO_PROGRAM}} found in the environment, but not any |
6477 | 134 commands in the system or user startup files that use the |
135 @code{info_program} function. | |
3294 | 136 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
137 @item --interactive |
3294 | 138 @itemx -i |
139 @cindex @code{--interactive} | |
140 @cindex @code{-i} | |
141 Force interactive behavior. This can be useful for running Octave via a | |
142 remote shell command or inside an Emacs shell buffer. For another way | |
9032
349616d9c38e
Cleanup top-level documentation menu in octave.texi
Rik <rdrider0-list@yahoo.com>
parents:
8923
diff
changeset
|
143 to run Octave within Emacs, see @ref{Emacs Octave Support}. |
3294 | 144 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
145 @item --line-editing |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
146 @cindex @code{--line-editing} |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
147 Force readline use for command-line editing. |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
148 |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
149 @item --no-history |
3428 | 150 @itemx -H |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
151 @cindex @code{--no-history} |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
152 @cindex @code{-H} |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
153 Disable recording of command-line history. |
3428 | 154 |
3294 | 155 @item --no-init-file |
156 @cindex @code{--no-init-file} | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
157 Don't read the initialization files @file{~/.octaverc} and @file{.octaverc}. |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
158 |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
159 @item --no-init-path |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
160 @cindex @code{--no-init-path} |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
161 Don't initialize the search path for function files to include default |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
162 locations. |
3294 | 163 |
164 @item --no-line-editing | |
165 @cindex @code{--no-line-editing} | |
166 Disable command-line editing. | |
167 | |
168 @item --no-site-file | |
169 @cindex @code{--no-site-file} | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
170 Don't read the site-wide @file{octaverc} initialization files. |
3294 | 171 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
172 @item --norc |
3294 | 173 @itemx -f |
174 @cindex @code{--norc} | |
175 @cindex @code{-f} | |
176 Don't read any of the system or user initialization files at startup. | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
177 This is equivalent to using both of the options @option{--no-init-file} |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
178 and @option{--no-site-file}. |
3294 | 179 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
180 @item --path @var{path} |
3294 | 181 @itemx -p @var{path} |
182 @cindex @code{--path @var{path}} | |
183 @cindex @code{-p @var{path}} | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
184 Add path to the head of the search path for function files. The |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
185 value of @var{path} specified on the command line will override any value |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
186 of @w{@env{OCTAVE_PATH}} found in the environment, but not any commands in the |
6643 | 187 system or user startup files that set the internal load path through one |
188 of the path functions. | |
3294 | 189 |
5190 | 190 @item --persist |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
191 @cindex @code{--persist} |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
192 Go to interactive mode after @option{--eval} or reading from a file |
5190 | 193 named on the command line. |
194 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
195 @item --silent |
3294 | 196 @itemx --quiet |
197 @itemx -q | |
198 @cindex @code{--silent} | |
199 @cindex @code{--quiet} | |
200 @cindex @code{-q} | |
201 Don't print the usual greeting and version message at startup. | |
202 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
203 @item --traditional |
3294 | 204 @itemx --braindead |
205 @cindex @code{--traditional} | |
206 @cindex @code{--braindead} | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9035
diff
changeset
|
207 For compatibility with @sc{matlab}, set initial values for |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
208 user preferences to the following values |
3294 | 209 |
210 @example | |
4455 | 211 @group |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
212 PS1 = ">> " |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
213 PS2 = "" |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
214 allow_noninteger_range_as_index = true |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
215 beep_on_error = true |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
216 confirm_recursive_rmdir = false |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
217 crash_dumps_octave_core = false |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
218 default_save_options = "-mat-binary" |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
219 fixed_point_format = true |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
220 history_timestamp_format_string = "%%-- %D %I:%M %p --%%" |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
221 page_screen_output = false |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
222 print_empty_dimensions = false |
6556 | 223 @end group |
224 @end example | |
225 | |
226 @noindent | |
227 and disable the following warnings | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
228 |
6556 | 229 @example |
230 @group | |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
9906
diff
changeset
|
231 Octave:abbreviated-property-match |
7031 | 232 Octave:fopen-file-in-path |
233 Octave:function-name-clash | |
234 Octave:load-file-in-path | |
4455 | 235 @end group |
3294 | 236 @end example |
237 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
238 @item --verbose |
3294 | 239 @itemx -V |
240 @cindex @code{--verbose} | |
241 @cindex @code{-V} | |
242 Turn on verbose output. | |
243 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
244 @item --version |
3294 | 245 @itemx -v |
246 @cindex @code{--version} | |
247 @cindex @code{-v} | |
248 Print the program version number and exit. | |
249 | |
250 @item @var{file} | |
5190 | 251 Execute commands from @var{file}. Exit when done unless |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
252 @option{--persist} is also specified. |
3294 | 253 @end table |
254 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
255 Octave also includes several functions which return information |
3294 | 256 about the command line, including the number of arguments and all of the |
257 options. | |
258 | |
3332 | 259 @DOCSTRING(argv) |
3294 | 260 |
6550 | 261 @DOCSTRING(program_name) |
262 | |
3332 | 263 @DOCSTRING(program_invocation_name) |
3294 | 264 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
265 Here is an example of using these functions to reproduce the command |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
266 line which invoked Octave. |
3294 | 267 |
268 @example | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
269 @group |
6479 | 270 printf ("%s", program_name ()); |
6620 | 271 arg_list = argv (); |
3294 | 272 for i = 1:nargin |
6479 | 273 printf (" %s", arg_list@{i@}); |
3294 | 274 endfor |
275 printf ("\n"); | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
276 @end group |
3294 | 277 @end example |
278 | |
279 @noindent | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
280 @xref{Indexing Cell Arrays}, for an explanation of how to retrieve objects |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
281 from cell arrays, and @ref{Defining Functions}, for information about the |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
282 variable @code{nargin}. |
3294 | 283 |
4167 | 284 @node Startup Files |
3294 | 285 @subsection Startup Files |
286 @cindex initialization | |
287 @cindex startup | |
288 | |
6620 | 289 When Octave starts, it looks for commands to execute from the files in |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
290 the following list. These files may contain any valid Octave commands, |
6620 | 291 including function definitions. |
3294 | 292 |
293 @cindex startup files | |
294 | |
295 @table @code | |
296 @item @var{octave-home}/share/octave/site/m/startup/octaverc | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
297 @cindex site startup file |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
298 where @var{octave-home} is the directory in which Octave is installed |
9906 | 299 (the default is @file{/usr/local}). |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
300 This file is provided so that changes to the default Octave environment |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
301 can be made globally for all users at your site for all versions of Octave |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
302 you have installed. Care should be taken when making changes to this file |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
303 since all users of Octave at your site will be affected. The default file |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
304 may be overridden by the environment variable @w{@env{OCTAVE_SITE_INITFILE}}. |
3294 | 305 |
306 @item @var{octave-home}/share/octave/@var{version}/m/startup/octaverc | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
307 @cindex version startup file |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
308 where @var{octave-home} is the directory in which Octave is |
9906 | 309 installed (the default is @file{/usr/local}), and @var{version} |
3294 | 310 is the version number of Octave. This file is provided so that changes |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
311 to the default Octave environment can be made globally for all users of |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
312 a particular version of Octave. Care should be taken when making |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
313 changes to this file since all users of Octave at your site will be |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
314 affected. The default file may be overridden by the environment variable |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
315 @w{@env{OCTAVE_VERSION_INITFILE}}. |
3294 | 316 |
317 @item ~/.octaverc | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
318 @cindex personal startup file |
3294 | 319 @cindex @code{~/.octaverc} |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
320 This file is used to make personal changes to the default |
3294 | 321 Octave environment. |
322 | |
323 @item .octaverc | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
324 @cindex project startup file |
3294 | 325 @cindex @code{.octaverc} |
326 This file can be used to make changes to the default Octave environment | |
327 for a particular project. Octave searches for this file in the current | |
328 directory after it reads @file{~/.octaverc}. Any use of the @code{cd} | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
329 command in the @file{~/.octaverc} file will affect the directory where |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
330 Octave searches for @file{.octaverc}. |
3294 | 331 |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8015
diff
changeset
|
332 If you start Octave in your home directory, commands from the file |
3294 | 333 @file{~/.octaverc} will only be executed once. |
334 @end table | |
335 | |
336 A message will be displayed as each of the startup files is read if you | |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
337 invoke Octave with the @option{--verbose} option but without the |
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
338 @option{--silent} option. |
3294 | 339 |
4167 | 340 @node Quitting Octave |
3294 | 341 @section Quitting Octave |
342 @cindex exiting octave | |
343 @cindex quitting octave | |
344 | |
3332 | 345 @DOCSTRING(quit) |
3294 | 346 |
3332 | 347 @DOCSTRING(atexit) |
3294 | 348 |
4167 | 349 @node Getting Help |
3294 | 350 @section Commands for Getting Help |
351 @cindex on-line help | |
352 @cindex help, on-line | |
353 | |
354 The entire text of this manual is available from the Octave prompt | |
6620 | 355 via the command @kbd{doc}. In addition, the documentation for |
3294 | 356 individual user-written functions and variables is also available via |
357 the @kbd{help} command. This section describes the commands used for | |
358 reading the manual and the documentation strings for user-supplied | |
359 functions and variables. @xref{Function Files}, for more information | |
360 about how to document the functions you write. | |
361 | |
3332 | 362 @DOCSTRING(help) |
3294 | 363 |
6549 | 364 @DOCSTRING(doc) |
365 | |
366 @DOCSTRING(lookfor) | |
367 | |
8817
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
368 To see what is new in the current release of Octave, use the @code{news} |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
369 function. |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
370 |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
371 @DOCSTRING(news) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
372 |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
373 @DOCSTRING(info) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
374 |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
375 @DOCSTRING(warranty) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
376 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
377 The following functions can be used to change which programs are used |
6620 | 378 for displaying the documentation, and where the documentation can be |
379 found. | |
3294 | 380 |
6477 | 381 @DOCSTRING(info_file) |
3294 | 382 |
6477 | 383 @DOCSTRING(info_program) |
3294 | 384 |
6477 | 385 @DOCSTRING(makeinfo_program) |
3686 | 386 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
387 @DOCSTRING(doc_cache_file) |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
388 |
3332 | 389 @DOCSTRING(suppress_verbose_help_message) |
3294 | 390 |
4167 | 391 @node Command Line Editing |
3294 | 392 @section Command Line Editing |
393 @cindex command-line editing | |
394 @cindex editing the command line | |
395 | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
396 Octave uses the GNU Readline library to provide an extensive set of |
3294 | 397 command-line editing and history features. Only the most common |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
398 features are described in this manual. In addition, all of the editing |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
399 functions can be bound to different key strokes at the user's discretion. |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
400 This manual assumes no changes from the default Emacs bindings. See the GNU |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
401 Readline Library manual for more information on customizing Readline and |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
402 for a complete feature list. |
3294 | 403 |
404 To insert printing characters (letters, digits, symbols, etc.), simply | |
405 type the character. Octave will insert the character at the cursor and | |
406 advance the cursor forward. | |
407 | |
408 Many of the command-line editing functions operate using control | |
409 characters. For example, the character @kbd{Control-a} moves the cursor | |
410 to the beginning of the line. To type @kbd{C-a}, hold down @key{CTRL} | |
411 and then press @key{a}. In the following sections, control characters | |
412 such as @kbd{Control-a} are written as @kbd{C-a}. | |
413 | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
414 Another set of command-line editing functions use Meta characters. To |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
415 type @kbd{M-u}, hold down the @key{META} key and press @key{u}. Depending |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
416 on the keyboard, the @key{META} key may be labeled @key{ALT} or |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
417 even @key{WINDOWS}. If your terminal does not have a @key{META} key, you |
7001 | 418 can still type Meta characters using two-character sequences starting |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
419 with @kbd{ESC}. Thus, to enter @kbd{M-u}, you would type |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
420 @key{ESC} @key{u}. The @kbd{ESC} character sequences are also allowed on |
3294 | 421 terminals with real Meta keys. In the following sections, Meta |
422 characters such as @kbd{Meta-u} are written as @kbd{M-u}. | |
423 | |
3428 | 424 |
3294 | 425 @menu |
426 * Cursor Motion:: | |
427 * Killing and Yanking:: | |
428 * Commands For Text:: | |
429 * Commands For Completion:: | |
430 * Commands For History:: | |
3439 | 431 * Customizing readline:: |
3294 | 432 * Customizing the Prompt:: |
433 * Diary and Echo Commands:: | |
434 @end menu | |
435 | |
4167 | 436 @node Cursor Motion |
3294 | 437 @subsection Cursor Motion |
438 | |
439 The following commands allow you to position the cursor. | |
440 | |
441 @table @kbd | |
442 @item C-b | |
443 Move back one character. | |
444 | |
445 @item C-f | |
446 Move forward one character. | |
447 | |
448 @item @key{DEL} | |
449 Delete the character to the left of the cursor. | |
450 | |
451 @item C-d | |
452 Delete the character underneath the cursor. | |
453 | |
454 @item M-f | |
455 Move forward a word. | |
456 | |
457 @item M-b | |
458 Move backward a word. | |
459 | |
460 @item C-a | |
461 Move to the start of the line. | |
462 | |
463 @item C-e | |
464 Move to the end of the line. | |
465 | |
466 @item C-l | |
467 Clear the screen, reprinting the current line at the top. | |
468 | |
469 @item C-_ | |
470 @itemx C-/ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
471 Undo the last action. You can undo all the way back to an empty line. |
3294 | 472 |
473 @item M-r | |
474 Undo all changes made to this line. This is like typing the `undo' | |
475 command enough times to get back to the beginning. | |
476 @end table | |
477 | |
478 The above table describes the most basic possible keystrokes that you need | |
479 in order to do editing of the input line. On most terminals, you can | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
480 also use the left and right arrow keys in place of @kbd{C-f} and @kbd{C-b} |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
481 to move forward and backward. |
3294 | 482 |
483 Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves | |
484 forward a word. It is a loose convention that control keystrokes | |
485 operate on characters while meta keystrokes operate on words. | |
486 | |
487 @cindex clearing the screen | |
488 | |
6620 | 489 The function @code{clc} will allow you to clear the screen from within |
490 Octave programs. | |
491 | |
3332 | 492 @DOCSTRING(clc) |
3294 | 493 |
4167 | 494 @node Killing and Yanking |
3294 | 495 @subsection Killing and Yanking |
496 | |
497 @dfn{Killing} text means to delete the text from the line, but to save | |
498 it away for later use, usually by @dfn{yanking} it back into the line. | |
499 If the description for a command says that it `kills' text, then you can | |
500 be sure that you can get the text back in a different (or the same) | |
501 place later. | |
502 | |
503 Here is the list of commands for killing text. | |
504 | |
505 @table @kbd | |
506 @item C-k | |
507 Kill the text from the current cursor position to the end of the line. | |
508 | |
509 @item M-d | |
510 Kill from the cursor to the end of the current word, or if between | |
511 words, to the end of the next word. | |
512 | |
513 @item M-@key{DEL} | |
514 Kill from the cursor to the start of the previous word, or if between | |
515 words, to the start of the previous word. | |
516 | |
517 @item C-w | |
518 Kill from the cursor to the previous whitespace. This is different than | |
519 @kbd{M-@key{DEL}} because the word boundaries differ. | |
520 @end table | |
521 | |
522 And, here is how to @dfn{yank} the text back into the line. Yanking | |
523 means to copy the most-recently-killed text from the kill buffer. | |
524 | |
525 @table @kbd | |
526 @item C-y | |
527 Yank the most recently killed text back into the buffer at the cursor. | |
528 | |
529 @item M-y | |
530 Rotate the kill-ring, and yank the new top. You can only do this if | |
531 the prior command is @kbd{C-y} or @kbd{M-y}. | |
532 @end table | |
533 | |
534 When you use a kill command, the text is saved in a @dfn{kill-ring}. | |
535 Any number of consecutive kills save all of the killed text together, so | |
536 that when you yank it back, you get it in one clean sweep. The kill | |
537 ring is not line specific; the text that you killed on a previously | |
538 typed line is available to be yanked back later, when you are typing | |
539 another line. | |
540 | |
4167 | 541 @node Commands For Text |
3294 | 542 @subsection Commands For Changing Text |
543 | |
544 The following commands can be used for entering characters that would | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
545 otherwise have a special meaning (e.g., @key{TAB}, @kbd{C-q}, etc.), or |
3294 | 546 for quickly correcting typing mistakes. |
547 | |
548 @table @kbd | |
549 @item C-q | |
550 @itemx C-v | |
551 Add the next character that you type to the line verbatim. This is | |
552 how to insert things like @kbd{C-q} for example. | |
553 | |
554 @item M-@key{TAB} | |
555 Insert a tab character. | |
556 | |
557 @item C-t | |
558 Drag the character before the cursor forward over the character at the | |
559 cursor, also moving the cursor forward. If the cursor is at the end of | |
560 the line, then transpose the two characters before it. | |
561 | |
562 @item M-t | |
563 Drag the word behind the cursor past the word in front of the cursor | |
564 moving the cursor over that word as well. | |
565 | |
566 @item M-u | |
567 Uppercase the characters following the cursor to the end of the current | |
568 (or following) word, moving the cursor to the end of the word. | |
569 | |
570 @item M-l | |
6620 | 571 Lowercase the characters following the cursor to the end of the current |
3294 | 572 (or following) word, moving the cursor to the end of the word. |
573 | |
574 @item M-c | |
575 Uppercase the character following the cursor (or the beginning of the | |
576 next word if the cursor is between words), moving the cursor to the end | |
577 of the word. | |
578 @end table | |
579 | |
4167 | 580 @node Commands For Completion |
3294 | 581 @subsection Letting Readline Type For You |
582 @cindex command completion | |
583 | |
584 The following commands allow Octave to complete command and variable | |
585 names for you. | |
586 | |
587 @table @kbd | |
588 @item @key{TAB} | |
589 Attempt to do completion on the text before the cursor. Octave can | |
590 complete the names of commands and variables. | |
591 | |
592 @item M-? | |
593 List the possible completions of the text before the cursor. | |
594 @end table | |
595 | |
3332 | 596 @DOCSTRING(completion_append_char) |
3294 | 597 |
3332 | 598 @DOCSTRING(completion_matches) |
3294 | 599 |
4167 | 600 @node Commands For History |
3294 | 601 @subsection Commands For Manipulating The History |
602 @cindex command history | |
603 @cindex input history | |
604 @cindex history of commands | |
605 | |
606 Octave normally keeps track of the commands you type so that you can | |
607 recall previous commands to edit or execute them again. When you exit | |
608 Octave, the most recent commands you have typed, up to the number | |
609 specified by the variable @code{history_size}, are saved in a file. | |
610 When Octave starts, it loads an initial list of commands from the file | |
611 named by the variable @code{history_file}. | |
612 | |
613 Here are the commands for simple browsing and searching the history | |
614 list. | |
615 | |
616 @table @kbd | |
617 @item @key{LFD} | |
618 @itemx @key{RET} | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
619 Accept the current line regardless of where the cursor is. If the line is |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
620 non-empty, add it to the history list. If the line was a history |
3294 | 621 line, then restore the history line to its original state. |
622 | |
623 @item C-p | |
624 Move `up' through the history list. | |
625 | |
626 @item C-n | |
627 Move `down' through the history list. | |
628 | |
629 @item M-< | |
630 Move to the first line in the history. | |
631 | |
632 @item M-> | |
633 Move to the end of the input history, i.e., the line you are entering! | |
634 | |
635 @item C-r | |
636 Search backward starting at the current line and moving `up' through | |
637 the history as necessary. This is an incremental search. | |
638 | |
639 @item C-s | |
640 Search forward starting at the current line and moving `down' through | |
641 the history as necessary. | |
642 @end table | |
643 | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
644 On most terminals, you can also use the up and down arrow keys in place |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
645 of @kbd{C-p} and @kbd{C-n} to move through the history list. |
3294 | 646 |
647 In addition to the keyboard commands for moving through the history | |
648 list, Octave provides three functions for viewing, editing, and | |
649 re-running chunks of commands from the history list. | |
650 | |
3332 | 651 @DOCSTRING(history) |
3294 | 652 |
3332 | 653 @DOCSTRING(edit_history) |
3294 | 654 |
3332 | 655 @DOCSTRING(run_history) |
3294 | 656 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
657 @noindent |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
658 Octave also allows you customize the details of when, where, and how history |
6620 | 659 is saved. |
3294 | 660 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
661 @DOCSTRING(saving_history) |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
662 |
3332 | 663 @DOCSTRING(history_file) |
3294 | 664 |
3332 | 665 @DOCSTRING(history_size) |
3294 | 666 |
6550 | 667 @DOCSTRING(history_timestamp_format_string) |
668 | |
6620 | 669 @DOCSTRING(EDITOR) |
670 | |
4167 | 671 @node Customizing readline |
3428 | 672 @subsection Customizing @code{readline} |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
673 @cindex @file{~/.inputrc} |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
674 @cindex customizing @code{readline} |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
675 @cindex @code{readline} customization |
3428 | 676 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
677 Octave uses the GNU Readline library for command-line editing and |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
678 history features. Readline is very flexible and can be modified through |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
679 a configuration file of commands (See the GNU Readline library for the |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
680 exact command syntax). The default configuration file is normally |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
681 @file{~/.inputrc}. |
6620 | 682 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
683 Octave provides two commands for initializing Readline and thereby changing |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
684 the command line behavior. |
3428 | 685 |
3439 | 686 @DOCSTRING(read_readline_init_file) |
3428 | 687 |
8817
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
688 @DOCSTRING(re_read_readline_init_file) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
689 |
4167 | 690 @node Customizing the Prompt |
3294 | 691 @subsection Customizing the Prompt |
692 @cindex prompt customization | |
693 @cindex customizing the prompt | |
694 | |
695 The following variables are available for customizing the appearance of | |
696 the command-line prompts. Octave allows the prompt to be customized by | |
697 inserting a number of backslash-escaped special characters that are | |
698 decoded as follows: | |
699 | |
700 @table @samp | |
701 @item \t | |
702 The time. | |
703 | |
704 @item \d | |
705 The date. | |
706 | |
707 @item \n | |
708 Begins a new line by printing the equivalent of a carriage return | |
709 followed by a line feed. | |
710 | |
711 @item \s | |
712 The name of the program (usually just @samp{octave}). | |
713 | |
714 @item \w | |
715 The current working directory. | |
716 | |
717 @item \W | |
718 The basename of the current working directory. | |
719 | |
720 @item \u | |
721 The username of the current user. | |
722 | |
723 @item \h | |
724 The hostname, up to the first `.'. | |
725 | |
726 @item \H | |
727 The hostname. | |
728 | |
729 @item \# | |
730 The command number of this command, counting from when Octave starts. | |
731 | |
732 @item \! | |
733 The history number of this command. This differs from @samp{\#} by the | |
734 number of commands in the history list when Octave starts. | |
735 | |
736 @item \$ | |
737 If the effective UID is 0, a @samp{#}, otherwise a @samp{$}. | |
738 | |
739 @item \nnn | |
740 The character whose character code in octal is @var{nnn}. | |
741 | |
742 @item \\ | |
743 A backslash. | |
744 @end table | |
745 | |
3332 | 746 @DOCSTRING(PS1) |
3294 | 747 |
3332 | 748 @DOCSTRING(PS2) |
3294 | 749 |
3332 | 750 @DOCSTRING(PS4) |
3294 | 751 |
4167 | 752 @node Diary and Echo Commands |
3294 | 753 @subsection Diary and Echo Commands |
754 @cindex diary of commands and output | |
6939 | 755 @cindex command and output logs |
3294 | 756 @cindex logging commands and output |
757 @cindex echoing executing commands | |
758 @cindex command echoing | |
759 | |
760 Octave's diary feature allows you to keep a log of all or part of an | |
761 interactive session by recording the input you type and the output that | |
762 Octave produces in a separate file. | |
763 | |
3332 | 764 @DOCSTRING(diary) |
3294 | 765 |
766 Sometimes it is useful to see the commands in a function or script as | |
767 they are being evaluated. This can be especially helpful for debugging | |
768 some kinds of problems. | |
769 | |
3332 | 770 @DOCSTRING(echo) |
3294 | 771 |
3332 | 772 @DOCSTRING(echo_executing_commands) |
3294 | 773 |
4167 | 774 @node Errors |
3294 | 775 @section How Octave Reports Errors |
776 @cindex error messages | |
777 @cindex messages, error | |
778 | |
779 Octave reports two kinds of errors for invalid programs. | |
780 | |
781 A @dfn{parse error} occurs if Octave cannot understand something you | |
782 have typed. For example, if you misspell a keyword, | |
783 | |
784 @example | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
785 octave:13> function y = f (x) y = x***2; endfunction |
3294 | 786 @end example |
787 | |
788 @noindent | |
789 Octave will respond immediately with a message like this: | |
790 | |
791 @example | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
792 @group |
3294 | 793 parse error: |
794 | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
795 syntax error |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
796 |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
797 >>> function y = f (x) y = x***2; endfunction |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
798 ^ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
799 @end group |
3294 | 800 @end example |
801 | |
802 @noindent | |
803 For most parse errors, Octave uses a caret (@samp{^}) to mark the point | |
804 on the line where it was unable to make sense of your input. In this | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
805 case, Octave generated an error message because the keyword for |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
806 exponentiation (@code{**}) was misspelled. It marked the error at the |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
807 third @samp{*} because the code leading up to this was correct but the final |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
808 @samp{*} was not understood. |
3294 | 809 |
810 Another class of error message occurs at evaluation time. These | |
811 errors are called @dfn{run-time errors}, or sometimes | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
812 @dfn{evaluation errors}, because they occur when your program is being |
3294 | 813 @dfn{run}, or @dfn{evaluated}. For example, if after correcting the |
814 mistake in the previous function definition, you type | |
815 | |
816 @example | |
817 octave:13> f () | |
818 @end example | |
819 | |
820 @noindent | |
821 Octave will respond with | |
822 | |
9153
5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents:
9135
diff
changeset
|
823 @example |
3294 | 824 @group |
825 error: `x' undefined near line 1 column 24 | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
826 error: called from: |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
827 error: f at line 1, column 22 |
3294 | 828 @end group |
9153
5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents:
9135
diff
changeset
|
829 @end example |
3294 | 830 |
6620 | 831 @noindent |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
832 This error message has several parts, and gives quite a bit of |
3294 | 833 information to help you locate the source of the error. The messages |
834 are generated from the point of the innermost error, and provide a | |
835 traceback of enclosing expressions and function calls. | |
836 | |
837 In the example above, the first line indicates that a variable named | |
838 @samp{x} was found to be undefined near line 1 and column 24 of some | |
839 function or expression. For errors occurring within functions, lines | |
840 are counted from the beginning of the file containing the function | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
841 definition. For errors occurring outside of an enclosing function, |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
842 the line number indicates the input line number, which is usually displayed |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
843 in the primary prompt string. |
3294 | 844 |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
845 The second and third lines of the error message indicate that the error |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
846 occurred within the function @code{f}. If the function @code{f} had been |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
847 called from within another function, for example, @code{g}, the list of |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
848 errors would have ended with one more line: |
3294 | 849 |
850 @example | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
851 error: g at line 1, column 17 |
3294 | 852 @end example |
853 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
854 These lists of function calls make it fairly easy to trace the |
3294 | 855 path your program took before the error occurred, and to correct the |
856 error before trying again. | |
857 | |
4167 | 858 @node Executable Octave Programs |
3294 | 859 @section Executable Octave Programs |
860 @cindex executable scripts | |
861 @cindex scripts | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
862 @cindex batch processing |
3294 | 863 @cindex self contained programs |
864 @cindex program, self contained | |
865 @cindex @samp{#!} | |
866 | |
867 Once you have learned Octave, you may want to write self-contained | |
868 Octave scripts, using the @samp{#!} script mechanism. You can do this | |
869 on GNU systems and on many Unix systems @footnote{The @samp{#!} | |
870 mechanism works on Unix systems derived from Berkeley Unix, System V | |
6481 | 871 Release 4, and some System V Release 3 systems.}. |
872 | |
873 Self-contained Octave scripts are useful when you want to write a | |
874 program which users can invoke without knowing that the program is | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
875 written in the Octave language. Octave scripts are also used for batch |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
876 processing of data files. Once an algorithm has been developed and tested |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
877 in the interactive portion of Octave, it can be committed to an executable |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
878 script and used again and again on new data files. |
3294 | 879 |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
880 As a trivial example of an executable Octave script, you might create a |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
881 text file named @file{hello}, containing the following lines: |
3294 | 882 |
883 @example | |
884 @group | |
885 #! @var{octave-interpreter-name} -qf | |
886 # a sample Octave program | |
887 printf ("Hello, world!\n"); | |
888 @end group | |
889 @end example | |
890 | |
891 @noindent | |
892 (where @var{octave-interpreter-name} should be replaced with the full | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
893 path and name of your Octave binary). Note that this will only work if |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
894 @samp{#!} appears at the very beginning of the file. After making the |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
895 file executable (with the @code{chmod} command on Unix systems), you can |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
896 simply type: |
3294 | 897 |
898 @example | |
899 hello | |
900 @end example | |
901 | |
902 @noindent | |
903 at the shell, and the system will arrange to run Octave as if you had | |
904 typed: | |
905 | |
906 @example | |
907 octave hello | |
908 @end example | |
909 | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
910 The line beginning with @samp{#!} lists the full path and filename of an |
3294 | 911 interpreter to be run, and an optional initial command line argument to |
912 pass to that interpreter. The operating system then runs the | |
913 interpreter with the given argument and the full argument list of the | |
914 executed program. The first argument in the list is the full file name | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
915 of the Octave executable. The rest of the argument list will either be |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
916 options to Octave, or data files, or both. The @samp{-qf} options are |
3294 | 917 usually specified in stand-alone Octave programs to prevent them from |
918 printing the normal startup message, and to keep them from behaving | |
919 differently depending on the contents of a particular user's | |
6620 | 920 @file{~/.octaverc} file. @xref{Invoking Octave from the Command Line}. |
6481 | 921 |
922 Note that some operating systems may place a limit on the number of | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
923 characters that are recognized after @samp{#!}. Also, the arguments |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
924 appearing in a @samp{#!} line are parsed differently by various |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
925 shells/systems. The majority of them group all the arguments together in one |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
926 string and pass it to the interpreter as a single argument. In this case, the |
6481 | 927 following script: |
928 | |
929 @example | |
930 @group | |
931 #! @var{octave-interpreter-name} -q -f # comment | |
932 @end group | |
933 @end example | |
934 | |
935 @noindent | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
936 is equivalent to typing at the command line: |
3294 | 937 |
6481 | 938 @example |
939 @group | |
940 octave "-q -f # comment" | |
941 @end group | |
942 @end example | |
3294 | 943 |
6481 | 944 @noindent |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
945 which will produce an error message. Unfortunately, it is |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
946 not possible for Octave to determine whether it has been called from the |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
947 command line or from a @samp{#!} script, so some care is needed when using the |
6481 | 948 @samp{#!} mechanism. |
949 | |
950 Note that when Octave is started from an executable script, the built-in | |
951 function @code{argv} returns a cell array containing the command line | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
952 arguments passed to the executable Octave script, not the arguments |
6481 | 953 passed to the Octave interpreter on the @samp{#!} line of the script. |
954 For example, the following program will reproduce the command line that | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
955 was used to execute the script, not @samp{-qf}. |
3294 | 956 |
957 @example | |
958 @group | |
959 #! /bin/octave -qf | |
6479 | 960 printf ("%s", program_name ()); |
6620 | 961 arg_list = argv (); |
3294 | 962 for i = 1:nargin |
6479 | 963 printf (" %s", arg_list@{i@}); |
3294 | 964 endfor |
965 printf ("\n"); | |
966 @end group | |
967 @end example | |
968 | |
4167 | 969 @node Comments |
3294 | 970 @section Comments in Octave Programs |
971 @cindex comments | |
972 @cindex use of comments | |
973 @cindex documenting Octave programs | |
974 | |
975 A @dfn{comment} is some text that is included in a program for the sake | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
976 of human readers, and which is NOT an executable part of the program. |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
977 Comments can explain what the program does, and how it works. Nearly all |
3294 | 978 programming languages have provisions for comments, because programs are |
979 typically hard to understand without them. | |
980 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
981 @menu |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
982 * Single Line Comments:: |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
983 * Block Comments:: |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
984 * Comments and the Help System:: |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
985 @end menu |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
986 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
987 @node Single Line Comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
988 @subsection Single Line Comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
989 @cindex @samp{#} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
990 @cindex @samp{%} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
991 |
3294 | 992 In the Octave language, a comment starts with either the sharp sign |
993 character, @samp{#}, or the percent symbol @samp{%} and continues to the | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
994 end of the line. Any text following the sharp sign or percent symbol is |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
995 ignored by the Octave interpreter and not executed. The following example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
996 shows whole line and partial line comments. |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
997 |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
998 @example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
999 @group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1000 function countdown |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1001 # Count down for main rocket engines |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1002 disp(3); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1003 disp(2); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1004 disp(1); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1005 disp("Blast Off!"); # Rocket leaves pad |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1006 endfunction |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1007 @end group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1008 @end example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1009 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1010 @node Block Comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1011 @subsection Block Comments |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1012 @cindex block comments |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1013 @cindex multi-line comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1014 @cindex @samp{#@{} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1015 @cindex @samp{%@{} |
3294 | 1016 |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1017 Entire blocks of code can be commented by enclosing the code between |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1018 matching @samp{#@{} and @samp{#@}} or @samp{%@{} and @samp{%@}} markers. |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1019 For example, |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
1020 |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1021 @example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1022 @group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1023 function quick_countdown |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1024 # Count down for main rocket engines |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1025 disp(3); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1026 #@{ |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1027 disp(2); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1028 disp(1); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1029 #@} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1030 disp("Blast Off!"); # Rocket leaves pad |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1031 endfunction |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1032 @end group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1033 @end example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1034 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1035 @noindent |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1036 will produce a very quick countdown from '3' to 'Blast Off' as the |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1037 lines "@code{disp(2);}" and "@code{disp(1);}" won't be executed. |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1038 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1039 @node Comments and the Help System |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1040 @subsection Comments and the Help System |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1041 @cindex documenting functions |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1042 @cindex documenting user scripts |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1043 @cindex help, user-defined functions |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1044 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1045 The @code{help} command (@pxref{Getting Help}) is able to find the first |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1046 block of comments in a function and return those as a documentation |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1047 string. This means that the same commands used to get help |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1048 on built-in functions are available for properly formatted user-defined |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1049 functions. For example, after defining the function @code{f} below, |
10828
322f43e0e170
Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
1050 |
3294 | 1051 @example |
1052 @group | |
1053 function xdot = f (x, t) | |
1054 | |
1055 # usage: f (x, t) | |
1056 # | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1057 # This function defines the right-hand |
3294 | 1058 # side functions for a set of nonlinear |
1059 # differential equations. | |
1060 | |
1061 r = 0.25; | |
1062 @dots{} | |
1063 endfunction | |
1064 @end group | |
1065 @end example | |
1066 | |
1067 the command @kbd{help f} produces the output | |
1068 | |
1069 @example | |
1070 @group | |
1071 usage: f (x, t) | |
1072 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1073 This function defines the right-hand |
3294 | 1074 side functions for a set of nonlinear |
1075 differential equations. | |
1076 @end group | |
1077 @end example | |
1078 | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1079 Although it is possible to put comment lines into keyboard-composed, |
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1080 throw-away Octave programs, it usually isn't very useful because the |
3294 | 1081 purpose of a comment is to help you or another person understand the |
1082 program at a later time. | |
1083 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1084 The @code{help} parser currently only recognizes single line comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1085 (@pxref{Single Line Comments}) and not block comments for the initial |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1086 help text. |