Mercurial > octave-nkf
annotate doc/interpreter/basics.txi @ 9153:5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Use @smallexample when necessary to reduce font for long lines.
Reword variables or phrases so that Tex can break them at a better spot.
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 24 Apr 2009 12:29:01 -0700 |
parents | b04f95fabbf9 |
children | 8d20fb66a0dc |
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 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
83 @w{@code{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} |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
94 Evaluate @var{code} and exit when finished unless @code{--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 | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
101 @w{@code{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 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
103 @w{@code{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 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
117 @w{@code{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 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
119 @w{@code{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 | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
125 @w{@code{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 | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
133 @w{@code{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. | |
177 This is equivalent to using both of the options @code{--no-init-file} | |
178 and @code{--no-site-file}. | |
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 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
186 of @w{@code{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} |
5190 | 192 Go to interactive mode after @code{--eval} or reading from a file |
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 |
7031 | 212 PS1 = ">> " |
213 PS2 = "" | |
214 beep_on_error = true | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
215 confirm_recursive_rmdir = false |
7031 | 216 crash_dumps_octave_core = false |
217 default_save_options = "-mat-binary" | |
218 fixed_point_format = true | |
219 history_timestamp_format_string | |
220 = "%%-- %D %I:%M %p --%%" | |
221 page_screen_output = false | |
222 print_empty_dimensions = false | |
6556 | 223 @end group |
224 @end example | |
225 | |
226 @noindent | |
227 and disable the following warnings | |
228 @example | |
229 @group | |
7031 | 230 Octave:fopen-file-in-path |
231 Octave:function-name-clash | |
232 Octave:load-file-in-path | |
4455 | 233 @end group |
3294 | 234 @end example |
235 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
236 @item --verbose |
3294 | 237 @itemx -V |
238 @cindex @code{--verbose} | |
239 @cindex @code{-V} | |
240 Turn on verbose output. | |
241 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
242 @item --version |
3294 | 243 @itemx -v |
244 @cindex @code{--version} | |
245 @cindex @code{-v} | |
246 Print the program version number and exit. | |
247 | |
248 @item @var{file} | |
5190 | 249 Execute commands from @var{file}. Exit when done unless |
250 @code{--persist} is also specified. | |
3294 | 251 @end table |
252 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
253 Octave also includes several functions which return information |
3294 | 254 about the command line, including the number of arguments and all of the |
255 options. | |
256 | |
3332 | 257 @DOCSTRING(argv) |
3294 | 258 |
6550 | 259 @DOCSTRING(program_name) |
260 | |
3332 | 261 @DOCSTRING(program_invocation_name) |
3294 | 262 |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
263 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
|
264 line which invoked Octave. |
3294 | 265 |
266 @example | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
267 @group |
6479 | 268 printf ("%s", program_name ()); |
6620 | 269 arg_list = argv (); |
3294 | 270 for i = 1:nargin |
6479 | 271 printf (" %s", arg_list@{i@}); |
3294 | 272 endfor |
273 printf ("\n"); | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
274 @end group |
3294 | 275 @end example |
276 | |
277 @noindent | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
278 @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
|
279 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
|
280 variable @code{nargin}. |
3294 | 281 |
4167 | 282 @node Startup Files |
3294 | 283 @subsection Startup Files |
284 @cindex initialization | |
285 @cindex startup | |
286 | |
6620 | 287 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
|
288 the following list. These files may contain any valid Octave commands, |
6620 | 289 including function definitions. |
3294 | 290 |
291 @cindex startup files | |
292 | |
293 @table @code | |
294 @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
|
295 @cindex site startup file |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
296 where @var{octave-home} is the directory in which Octave is installed |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
297 (the default is @file{@value{OCTAVEHOME}}). |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 since all users of Octave at your site will be affected. The default file |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
302 may be overridden by the environment variable @w{@code{OCTAVE_SITE_INITFILE}}. |
3294 | 303 |
304 @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
|
305 @cindex version startup file |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
306 where @var{octave-home} is the directory in which Octave is |
3294 | 307 installed (the default is @file{@value{OCTAVEHOME}}), and @var{version} |
308 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
|
309 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
|
310 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
|
311 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
|
312 affected. The default file may be overridden by the environment variable |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
313 @w{@code{OCTAVE_VERSION_INITFILE}}. |
3294 | 314 |
315 @item ~/.octaverc | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
316 @cindex personal startup file |
3294 | 317 @cindex @code{~/.octaverc} |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
318 This file is used to make personal changes to the default |
3294 | 319 Octave environment. |
320 | |
321 @item .octaverc | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
322 @cindex project startup file |
3294 | 323 @cindex @code{.octaverc} |
324 This file can be used to make changes to the default Octave environment | |
325 for a particular project. Octave searches for this file in the current | |
326 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
|
327 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
|
328 Octave searches for @file{.octaverc}. |
3294 | 329 |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8015
diff
changeset
|
330 If you start Octave in your home directory, commands from the file |
3294 | 331 @file{~/.octaverc} will only be executed once. |
332 @end table | |
333 | |
334 A message will be displayed as each of the startup files is read if you | |
335 invoke Octave with the @code{--verbose} option but without the | |
336 @code{--silent} option. | |
337 | |
4167 | 338 @node Quitting Octave |
3294 | 339 @section Quitting Octave |
340 @cindex exiting octave | |
341 @cindex quitting octave | |
342 | |
3332 | 343 @DOCSTRING(quit) |
3294 | 344 |
3332 | 345 @DOCSTRING(atexit) |
3294 | 346 |
4167 | 347 @node Getting Help |
3294 | 348 @section Commands for Getting Help |
349 @cindex on-line help | |
350 @cindex help, on-line | |
351 | |
352 The entire text of this manual is available from the Octave prompt | |
6620 | 353 via the command @kbd{doc}. In addition, the documentation for |
3294 | 354 individual user-written functions and variables is also available via |
355 the @kbd{help} command. This section describes the commands used for | |
356 reading the manual and the documentation strings for user-supplied | |
357 functions and variables. @xref{Function Files}, for more information | |
358 about how to document the functions you write. | |
359 | |
3332 | 360 @DOCSTRING(help) |
3294 | 361 |
6549 | 362 @DOCSTRING(doc) |
363 | |
364 @DOCSTRING(lookfor) | |
365 | |
8817
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
366 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
|
367 function. |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
368 |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
369 @DOCSTRING(news) |
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(info) |
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(warranty) |
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
374 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
375 The following functions can be used to change which programs are used |
6620 | 376 for displaying the documentation, and where the documentation can be |
377 found. | |
3294 | 378 |
6477 | 379 @DOCSTRING(info_file) |
3294 | 380 |
6477 | 381 @DOCSTRING(info_program) |
3294 | 382 |
6477 | 383 @DOCSTRING(makeinfo_program) |
3686 | 384 |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
385 @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
|
386 |
3332 | 387 @DOCSTRING(suppress_verbose_help_message) |
3294 | 388 |
4167 | 389 @node Command Line Editing |
3294 | 390 @section Command Line Editing |
391 @cindex command-line editing | |
392 @cindex editing the command line | |
393 | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
394 Octave uses the GNU Readline library to provide an extensive set of |
3294 | 395 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
|
396 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
|
397 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
|
398 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
|
399 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
|
400 for a complete feature list. |
3294 | 401 |
402 To insert printing characters (letters, digits, symbols, etc.), simply | |
403 type the character. Octave will insert the character at the cursor and | |
404 advance the cursor forward. | |
405 | |
406 Many of the command-line editing functions operate using control | |
407 characters. For example, the character @kbd{Control-a} moves the cursor | |
408 to the beginning of the line. To type @kbd{C-a}, hold down @key{CTRL} | |
409 and then press @key{a}. In the following sections, control characters | |
410 such as @kbd{Control-a} are written as @kbd{C-a}. | |
411 | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
412 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
|
413 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
|
414 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
|
415 even @key{WINDOWS}. If your terminal does not have a @key{META} key, you |
7001 | 416 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
|
417 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
|
418 @key{ESC} @key{u}. The @kbd{ESC} character sequences are also allowed on |
3294 | 419 terminals with real Meta keys. In the following sections, Meta |
420 characters such as @kbd{Meta-u} are written as @kbd{M-u}. | |
421 | |
3428 | 422 |
3294 | 423 @menu |
424 * Cursor Motion:: | |
425 * Killing and Yanking:: | |
426 * Commands For Text:: | |
427 * Commands For Completion:: | |
428 * Commands For History:: | |
3439 | 429 * Customizing readline:: |
3294 | 430 * Customizing the Prompt:: |
431 * Diary and Echo Commands:: | |
432 @end menu | |
433 | |
4167 | 434 @node Cursor Motion |
3294 | 435 @subsection Cursor Motion |
436 | |
437 The following commands allow you to position the cursor. | |
438 | |
439 @table @kbd | |
440 @item C-b | |
441 Move back one character. | |
442 | |
443 @item C-f | |
444 Move forward one character. | |
445 | |
446 @item @key{DEL} | |
447 Delete the character to the left of the cursor. | |
448 | |
449 @item C-d | |
450 Delete the character underneath the cursor. | |
451 | |
452 @item M-f | |
453 Move forward a word. | |
454 | |
455 @item M-b | |
456 Move backward a word. | |
457 | |
458 @item C-a | |
459 Move to the start of the line. | |
460 | |
461 @item C-e | |
462 Move to the end of the line. | |
463 | |
464 @item C-l | |
465 Clear the screen, reprinting the current line at the top. | |
466 | |
467 @item C-_ | |
468 @itemx C-/ | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
469 Undo the last action. You can undo all the way back to an empty line. |
3294 | 470 |
471 @item M-r | |
472 Undo all changes made to this line. This is like typing the `undo' | |
473 command enough times to get back to the beginning. | |
474 @end table | |
475 | |
476 The above table describes the most basic possible keystrokes that you need | |
477 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
|
478 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
|
479 to move forward and backward. |
3294 | 480 |
481 Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves | |
482 forward a word. It is a loose convention that control keystrokes | |
483 operate on characters while meta keystrokes operate on words. | |
484 | |
485 @cindex clearing the screen | |
486 | |
6620 | 487 The function @code{clc} will allow you to clear the screen from within |
488 Octave programs. | |
489 | |
3332 | 490 @DOCSTRING(clc) |
3294 | 491 |
4167 | 492 @node Killing and Yanking |
3294 | 493 @subsection Killing and Yanking |
494 | |
495 @dfn{Killing} text means to delete the text from the line, but to save | |
496 it away for later use, usually by @dfn{yanking} it back into the line. | |
497 If the description for a command says that it `kills' text, then you can | |
498 be sure that you can get the text back in a different (or the same) | |
499 place later. | |
500 | |
501 Here is the list of commands for killing text. | |
502 | |
503 @table @kbd | |
504 @item C-k | |
505 Kill the text from the current cursor position to the end of the line. | |
506 | |
507 @item M-d | |
508 Kill from the cursor to the end of the current word, or if between | |
509 words, to the end of the next word. | |
510 | |
511 @item M-@key{DEL} | |
512 Kill from the cursor to the start of the previous word, or if between | |
513 words, to the start of the previous word. | |
514 | |
515 @item C-w | |
516 Kill from the cursor to the previous whitespace. This is different than | |
517 @kbd{M-@key{DEL}} because the word boundaries differ. | |
518 @end table | |
519 | |
520 And, here is how to @dfn{yank} the text back into the line. Yanking | |
521 means to copy the most-recently-killed text from the kill buffer. | |
522 | |
523 @table @kbd | |
524 @item C-y | |
525 Yank the most recently killed text back into the buffer at the cursor. | |
526 | |
527 @item M-y | |
528 Rotate the kill-ring, and yank the new top. You can only do this if | |
529 the prior command is @kbd{C-y} or @kbd{M-y}. | |
530 @end table | |
531 | |
532 When you use a kill command, the text is saved in a @dfn{kill-ring}. | |
533 Any number of consecutive kills save all of the killed text together, so | |
534 that when you yank it back, you get it in one clean sweep. The kill | |
535 ring is not line specific; the text that you killed on a previously | |
536 typed line is available to be yanked back later, when you are typing | |
537 another line. | |
538 | |
4167 | 539 @node Commands For Text |
3294 | 540 @subsection Commands For Changing Text |
541 | |
542 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
|
543 otherwise have a special meaning (e.g., @key{TAB}, @kbd{C-q}, etc.), or |
3294 | 544 for quickly correcting typing mistakes. |
545 | |
546 @table @kbd | |
547 @item C-q | |
548 @itemx C-v | |
549 Add the next character that you type to the line verbatim. This is | |
550 how to insert things like @kbd{C-q} for example. | |
551 | |
552 @item M-@key{TAB} | |
553 Insert a tab character. | |
554 | |
555 @item C-t | |
556 Drag the character before the cursor forward over the character at the | |
557 cursor, also moving the cursor forward. If the cursor is at the end of | |
558 the line, then transpose the two characters before it. | |
559 | |
560 @item M-t | |
561 Drag the word behind the cursor past the word in front of the cursor | |
562 moving the cursor over that word as well. | |
563 | |
564 @item M-u | |
565 Uppercase the characters following the cursor to the end of the current | |
566 (or following) word, moving the cursor to the end of the word. | |
567 | |
568 @item M-l | |
6620 | 569 Lowercase the characters following the cursor to the end of the current |
3294 | 570 (or following) word, moving the cursor to the end of the word. |
571 | |
572 @item M-c | |
573 Uppercase the character following the cursor (or the beginning of the | |
574 next word if the cursor is between words), moving the cursor to the end | |
575 of the word. | |
576 @end table | |
577 | |
4167 | 578 @node Commands For Completion |
3294 | 579 @subsection Letting Readline Type For You |
580 @cindex command completion | |
581 | |
582 The following commands allow Octave to complete command and variable | |
583 names for you. | |
584 | |
585 @table @kbd | |
586 @item @key{TAB} | |
587 Attempt to do completion on the text before the cursor. Octave can | |
588 complete the names of commands and variables. | |
589 | |
590 @item M-? | |
591 List the possible completions of the text before the cursor. | |
592 @end table | |
593 | |
3332 | 594 @DOCSTRING(completion_append_char) |
3294 | 595 |
3332 | 596 @DOCSTRING(completion_matches) |
3294 | 597 |
4167 | 598 @node Commands For History |
3294 | 599 @subsection Commands For Manipulating The History |
600 @cindex command history | |
601 @cindex input history | |
602 @cindex history of commands | |
603 | |
604 Octave normally keeps track of the commands you type so that you can | |
605 recall previous commands to edit or execute them again. When you exit | |
606 Octave, the most recent commands you have typed, up to the number | |
607 specified by the variable @code{history_size}, are saved in a file. | |
608 When Octave starts, it loads an initial list of commands from the file | |
609 named by the variable @code{history_file}. | |
610 | |
611 Here are the commands for simple browsing and searching the history | |
612 list. | |
613 | |
614 @table @kbd | |
615 @item @key{LFD} | |
616 @itemx @key{RET} | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
617 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
|
618 non-empty, add it to the history list. If the line was a history |
3294 | 619 line, then restore the history line to its original state. |
620 | |
621 @item C-p | |
622 Move `up' through the history list. | |
623 | |
624 @item C-n | |
625 Move `down' through the history list. | |
626 | |
627 @item M-< | |
628 Move to the first line in the history. | |
629 | |
630 @item M-> | |
631 Move to the end of the input history, i.e., the line you are entering! | |
632 | |
633 @item C-r | |
634 Search backward starting at the current line and moving `up' through | |
635 the history as necessary. This is an incremental search. | |
636 | |
637 @item C-s | |
638 Search forward starting at the current line and moving `down' through | |
639 the history as necessary. | |
640 @end table | |
641 | |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
642 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
|
643 of @kbd{C-p} and @kbd{C-n} to move through the history list. |
3294 | 644 |
645 In addition to the keyboard commands for moving through the history | |
646 list, Octave provides three functions for viewing, editing, and | |
647 re-running chunks of commands from the history list. | |
648 | |
3332 | 649 @DOCSTRING(history) |
3294 | 650 |
3332 | 651 @DOCSTRING(edit_history) |
3294 | 652 |
3332 | 653 @DOCSTRING(run_history) |
3294 | 654 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
655 @noindent |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
656 Octave also allows you customize the details of when, where, and how history |
6620 | 657 is saved. |
3294 | 658 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
659 @DOCSTRING(saving_history) |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
660 |
3332 | 661 @DOCSTRING(history_file) |
3294 | 662 |
3332 | 663 @DOCSTRING(history_size) |
3294 | 664 |
6550 | 665 @DOCSTRING(history_timestamp_format_string) |
666 | |
6620 | 667 @DOCSTRING(EDITOR) |
668 | |
4167 | 669 @node Customizing readline |
3428 | 670 @subsection Customizing @code{readline} |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
671 @cindex @file{~/.inputrc} |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
672 @cindex customizing @code{readline} |
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
673 @cindex @code{readline} customization |
3428 | 674 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
675 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
|
676 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
|
677 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
|
678 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
|
679 @file{~/.inputrc}. |
6620 | 680 |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9133
diff
changeset
|
681 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
|
682 the command line behavior. |
3428 | 683 |
3439 | 684 @DOCSTRING(read_readline_init_file) |
3428 | 685 |
8817
03b7f618ab3d
include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
686 @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
|
687 |
4167 | 688 @node Customizing the Prompt |
3294 | 689 @subsection Customizing the Prompt |
690 @cindex prompt customization | |
691 @cindex customizing the prompt | |
692 | |
693 The following variables are available for customizing the appearance of | |
694 the command-line prompts. Octave allows the prompt to be customized by | |
695 inserting a number of backslash-escaped special characters that are | |
696 decoded as follows: | |
697 | |
698 @table @samp | |
699 @item \t | |
700 The time. | |
701 | |
702 @item \d | |
703 The date. | |
704 | |
705 @item \n | |
706 Begins a new line by printing the equivalent of a carriage return | |
707 followed by a line feed. | |
708 | |
709 @item \s | |
710 The name of the program (usually just @samp{octave}). | |
711 | |
712 @item \w | |
713 The current working directory. | |
714 | |
715 @item \W | |
716 The basename of the current working directory. | |
717 | |
718 @item \u | |
719 The username of the current user. | |
720 | |
721 @item \h | |
722 The hostname, up to the first `.'. | |
723 | |
724 @item \H | |
725 The hostname. | |
726 | |
727 @item \# | |
728 The command number of this command, counting from when Octave starts. | |
729 | |
730 @item \! | |
731 The history number of this command. This differs from @samp{\#} by the | |
732 number of commands in the history list when Octave starts. | |
733 | |
734 @item \$ | |
735 If the effective UID is 0, a @samp{#}, otherwise a @samp{$}. | |
736 | |
737 @item \nnn | |
738 The character whose character code in octal is @var{nnn}. | |
739 | |
740 @item \\ | |
741 A backslash. | |
742 @end table | |
743 | |
3332 | 744 @DOCSTRING(PS1) |
3294 | 745 |
3332 | 746 @DOCSTRING(PS2) |
3294 | 747 |
3332 | 748 @DOCSTRING(PS4) |
3294 | 749 |
4167 | 750 @node Diary and Echo Commands |
3294 | 751 @subsection Diary and Echo Commands |
752 @cindex diary of commands and output | |
6939 | 753 @cindex command and output logs |
3294 | 754 @cindex logging commands and output |
755 @cindex echoing executing commands | |
756 @cindex command echoing | |
757 | |
758 Octave's diary feature allows you to keep a log of all or part of an | |
759 interactive session by recording the input you type and the output that | |
760 Octave produces in a separate file. | |
761 | |
3332 | 762 @DOCSTRING(diary) |
3294 | 763 |
764 Sometimes it is useful to see the commands in a function or script as | |
765 they are being evaluated. This can be especially helpful for debugging | |
766 some kinds of problems. | |
767 | |
3332 | 768 @DOCSTRING(echo) |
3294 | 769 |
3332 | 770 @DOCSTRING(echo_executing_commands) |
3294 | 771 |
4167 | 772 @node Errors |
3294 | 773 @section How Octave Reports Errors |
774 @cindex error messages | |
775 @cindex messages, error | |
776 | |
777 Octave reports two kinds of errors for invalid programs. | |
778 | |
779 A @dfn{parse error} occurs if Octave cannot understand something you | |
780 have typed. For example, if you misspell a keyword, | |
781 | |
782 @example | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
783 octave:13> function y = f (x) y = x***2; endfunction |
3294 | 784 @end example |
785 | |
786 @noindent | |
787 Octave will respond immediately with a message like this: | |
788 | |
789 @example | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
790 @group |
3294 | 791 parse error: |
792 | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
793 syntax error |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
794 |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
795 >>> 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
|
796 ^ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
797 @end group |
3294 | 798 @end example |
799 | |
800 @noindent | |
801 For most parse errors, Octave uses a caret (@samp{^}) to mark the point | |
802 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
|
803 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
|
804 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
|
805 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
|
806 @samp{*} was not understood. |
3294 | 807 |
808 Another class of error message occurs at evaluation time. These | |
809 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
|
810 @dfn{evaluation errors}, because they occur when your program is being |
3294 | 811 @dfn{run}, or @dfn{evaluated}. For example, if after correcting the |
812 mistake in the previous function definition, you type | |
813 | |
814 @example | |
815 octave:13> f () | |
816 @end example | |
817 | |
818 @noindent | |
819 Octave will respond with | |
820 | |
9153
5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents:
9135
diff
changeset
|
821 @example |
3294 | 822 @group |
823 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
|
824 error: called from: |
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
825 error: f at line 1, column 22 |
3294 | 826 @end group |
9153
5247e89688e1
Eliminate most overfull errors when running texi2pdf for generating pdf documentation
Rik <rdrider0-list@yahoo.com>
parents:
9135
diff
changeset
|
827 @end example |
3294 | 828 |
6620 | 829 @noindent |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
830 This error message has several parts, and gives quite a bit of |
3294 | 831 information to help you locate the source of the error. The messages |
832 are generated from the point of the innermost error, and provide a | |
833 traceback of enclosing expressions and function calls. | |
834 | |
835 In the example above, the first line indicates that a variable named | |
836 @samp{x} was found to be undefined near line 1 and column 24 of some | |
837 function or expression. For errors occurring within functions, lines | |
838 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
|
839 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
|
840 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
|
841 in the primary prompt string. |
3294 | 842 |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
843 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
|
844 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
|
845 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
|
846 errors would have ended with one more line: |
3294 | 847 |
848 @example | |
8015
30629059b72d
Update the manual to reflect the changes in error output
sh@sh-laptop
parents:
7031
diff
changeset
|
849 error: g at line 1, column 17 |
3294 | 850 @end example |
851 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
852 These lists of function calls make it fairly easy to trace the |
3294 | 853 path your program took before the error occurred, and to correct the |
854 error before trying again. | |
855 | |
4167 | 856 @node Executable Octave Programs |
3294 | 857 @section Executable Octave Programs |
858 @cindex executable scripts | |
859 @cindex scripts | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
860 @cindex batch processing |
3294 | 861 @cindex self contained programs |
862 @cindex program, self contained | |
863 @cindex @samp{#!} | |
864 | |
865 Once you have learned Octave, you may want to write self-contained | |
866 Octave scripts, using the @samp{#!} script mechanism. You can do this | |
867 on GNU systems and on many Unix systems @footnote{The @samp{#!} | |
868 mechanism works on Unix systems derived from Berkeley Unix, System V | |
6481 | 869 Release 4, and some System V Release 3 systems.}. |
870 | |
871 Self-contained Octave scripts are useful when you want to write a | |
872 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
|
873 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
|
874 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
|
875 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
|
876 script and used again and again on new data files. |
3294 | 877 |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
878 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
|
879 text file named @file{hello}, containing the following lines: |
3294 | 880 |
881 @example | |
882 @group | |
883 #! @var{octave-interpreter-name} -qf | |
884 # a sample Octave program | |
885 printf ("Hello, world!\n"); | |
886 @end group | |
887 @end example | |
888 | |
889 @noindent | |
890 (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
|
891 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
|
892 @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
|
893 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
|
894 simply type: |
3294 | 895 |
896 @example | |
897 hello | |
898 @end example | |
899 | |
900 @noindent | |
901 at the shell, and the system will arrange to run Octave as if you had | |
902 typed: | |
903 | |
904 @example | |
905 octave hello | |
906 @end example | |
907 | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
908 The line beginning with @samp{#!} lists the full path and filename of an |
3294 | 909 interpreter to be run, and an optional initial command line argument to |
910 pass to that interpreter. The operating system then runs the | |
911 interpreter with the given argument and the full argument list of the | |
912 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
|
913 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
|
914 options to Octave, or data files, or both. The @samp{-qf} options are |
3294 | 915 usually specified in stand-alone Octave programs to prevent them from |
916 printing the normal startup message, and to keep them from behaving | |
917 differently depending on the contents of a particular user's | |
6620 | 918 @file{~/.octaverc} file. @xref{Invoking Octave from the Command Line}. |
6481 | 919 |
920 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
|
921 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
|
922 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
|
923 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
|
924 string and pass it to the interpreter as a single argument. In this case, the |
6481 | 925 following script: |
926 | |
927 @example | |
928 @group | |
929 #! @var{octave-interpreter-name} -q -f # comment | |
930 @end group | |
931 @end example | |
932 | |
933 @noindent | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
934 is equivalent to typing at the command line: |
3294 | 935 |
6481 | 936 @example |
937 @group | |
938 octave "-q -f # comment" | |
939 @end group | |
940 @end example | |
3294 | 941 |
6481 | 942 @noindent |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
943 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
|
944 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
|
945 command line or from a @samp{#!} script, so some care is needed when using the |
6481 | 946 @samp{#!} mechanism. |
947 | |
948 Note that when Octave is started from an executable script, the built-in | |
949 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
|
950 arguments passed to the executable Octave script, not the arguments |
6481 | 951 passed to the Octave interpreter on the @samp{#!} line of the script. |
952 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
|
953 was used to execute the script, not @samp{-qf}. |
3294 | 954 |
955 @example | |
956 @group | |
957 #! /bin/octave -qf | |
6479 | 958 printf ("%s", program_name ()); |
6620 | 959 arg_list = argv (); |
3294 | 960 for i = 1:nargin |
6479 | 961 printf (" %s", arg_list@{i@}); |
3294 | 962 endfor |
963 printf ("\n"); | |
964 @end group | |
965 @end example | |
966 | |
4167 | 967 @node Comments |
3294 | 968 @section Comments in Octave Programs |
969 @cindex comments | |
970 @cindex use of comments | |
971 @cindex documenting Octave programs | |
972 | |
973 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
|
974 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
|
975 Comments can explain what the program does, and how it works. Nearly all |
3294 | 976 programming languages have provisions for comments, because programs are |
977 typically hard to understand without them. | |
978 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
979 @menu |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
980 * Single Line Comments:: |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
981 * Block Comments:: |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
982 * Comments and the Help System:: |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
983 @end menu |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
984 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
985 @node Single Line Comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
986 @subsection Single Line Comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
987 @cindex @samp{#} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
988 @cindex @samp{%} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
989 |
3294 | 990 In the Octave language, a comment starts with either the sharp sign |
991 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
|
992 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
|
993 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
|
994 shows whole line and partial line comments. |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
995 @example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
996 @group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
997 function countdown |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
998 # Count down for main rocket engines |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
999 disp(3); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1000 disp(2); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1001 disp(1); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1002 disp("Blast Off!"); # Rocket leaves pad |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1003 endfunction |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1004 @end group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1005 @end example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1006 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1007 @node Block Comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1008 @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
|
1009 @cindex block comments |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1010 @cindex multi-line comments |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1011 @cindex @samp{#@{} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1012 @cindex @samp{%@{} |
3294 | 1013 |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1014 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
|
1015 matching @samp{#@{} and @samp{#@}} or @samp{%@{} and @samp{%@}} markers. |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1016 For example, |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1017 @example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1018 @group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1019 function quick_countdown |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1020 # Count down for main rocket engines |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1021 disp(3); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1022 #@{ |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1023 disp(2); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1024 disp(1); |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1025 #@} |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1026 disp("Blast Off!"); # Rocket leaves pad |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1027 endfunction |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1028 @end group |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1029 @end example |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1030 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1031 @noindent |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1032 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
|
1033 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
|
1034 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1035 @node Comments and the Help System |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1036 @subsection Comments and the Help System |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1037 @cindex documenting functions |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1038 @cindex documenting user scripts |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1039 @cindex help, user-defined functions |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1040 |
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 functions. For example, after defining the function @code{f} below, |
3294 | 1046 @example |
1047 @group | |
1048 function xdot = f (x, t) | |
1049 | |
1050 # usage: f (x, t) | |
1051 # | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1052 # This function defines the right-hand |
3294 | 1053 # side functions for a set of nonlinear |
1054 # differential equations. | |
1055 | |
1056 r = 0.25; | |
1057 @dots{} | |
1058 endfunction | |
1059 @end group | |
1060 @end example | |
1061 | |
1062 the command @kbd{help f} produces the output | |
1063 | |
1064 @example | |
1065 @group | |
1066 usage: f (x, t) | |
1067 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1068 This function defines the right-hand |
3294 | 1069 side functions for a set of nonlinear |
1070 differential equations. | |
1071 @end group | |
1072 @end example | |
1073 | |
9135
b04f95fabbf9
Update sections 2.5, 2.6, 2.7 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9134
diff
changeset
|
1074 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
|
1075 throw-away Octave programs, it usually isn't very useful because the |
3294 | 1076 purpose of a comment is to help you or another person understand the |
1077 program at a later time. | |
1078 | |
9035
57649dcecb55
Documentation cleanup of basics.texi
Rik <rdrider0-list@yahoo.com>
parents:
9032
diff
changeset
|
1079 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
|
1080 (@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
|
1081 help text. |