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