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