comparison doc/interpreter/func.txi @ 11392:757efa1d7e2a

Remove deprecated functions from manual.
author Rik <octave@nomad.inbox5.com>
date Sat, 18 Dec 2010 14:37:11 -0800
parents 8d4c57258523
children 7b563cf94d8d
comparison
equal deleted inserted replaced
11391:98d523608f70 11392:757efa1d7e2a
1204 @node Commands 1204 @node Commands
1205 @section Commands 1205 @section Commands
1206 1206
1207 Commands are a special class of functions that only accept string 1207 Commands are a special class of functions that only accept string
1208 input arguments. A command can be called as an ordinary function, but 1208 input arguments. A command can be called as an ordinary function, but
1209 it can also be called without the parentheses like the following example 1209 it can also be called without the parentheses. For example,
1210 shows
1211 1210
1212 @example 1211 @example
1213 my_command hello world 1212 my_command hello world
1214 @end example 1213 @end example
1215 1214
1216 @noindent 1215 @noindent
1217 which is the same as 1216 is equivalent to
1218 1217
1219 @example 1218 @example
1220 my_command("hello", "world") 1219 my_command("hello", "world")
1221 @end example 1220 @end example
1222 1221
1222 @noindent
1223 The general form of a command call is 1223 The general form of a command call is
1224 1224
1225 @example 1225 @example
1226 @var{name} @var{arg1} @var{arg2} @dots{} 1226 @var{cmdname} @var{arg1} @var{arg2} @dots{}
1227 @end example 1227 @end example
1228 1228
1229 @noindent 1229 @noindent
1230 which translates directly to 1230 which translates directly to
1231 1231
1232 @example 1232 @example
1233 @var{name} ("@var{arg1}", "@var{arg2}", @dots{}) 1233 @var{cmdname} ("@var{arg1}", "@var{arg2}", @dots{})
1234 @end example 1234 @end example
1235 1235
1236 A function can be used as a command if it accepts string input arguments. 1236 Any regular function can be used as a command if it accepts string input
1237 To do this, the function must be marked as a command, which can be done 1237 arguments. For example:
1238 with the @code{mark_as_command} command like this 1238 @example
1239 1239 @group
1240 @example 1240 toupper lower_case_arg
1241 mark_as_command name 1241 @result{} ans = LOWER_CASE_ARG
1242 @end example 1242 @end group
1243 1243 @end example
1244 @noindent
1245 where @code{name} is the function to be marked as a command.
1246 1244
1247 One difficulty of commands occurs when one of the string input arguments 1245 One difficulty of commands occurs when one of the string input arguments
1248 are stored in a variable. Since Octave can't tell the difference between 1246 is stored in a variable. Because Octave can't tell the difference between
1249 a variable name, and an ordinary string, it is not possible to pass a 1247 a variable name and an ordinary string, it is not possible to pass a
1250 variable as input to a command. In such a situation a command must be 1248 variable as input to a command. In such a situation a command must be
1251 called as a function. 1249 called as a function. For example:
1252 1250
1253 @DOCSTRING(mark_as_command) 1251 @example
1254 1252 @group
1255 @DOCSTRING(unmark_command) 1253 strvar = "hello world";
1256 1254 toupper strvar
1257 @DOCSTRING(iscommand) 1255 @result{} ans = STRVAR
1258 1256 toupper (strvar)
1259 @DOCSTRING(mark_as_rawcommand) 1257 @result{} ans = HELLO WORLD
1260 1258 @end group
1261 @DOCSTRING(unmark_rawcommand) 1259 @end example
1262 1260
1263 @DOCSTRING(israwcommand)
1264 1261
1265 @node Organization of Functions 1262 @node Organization of Functions
1266 @section Organization of Functions Distributed with Octave 1263 @section Organization of Functions Distributed with Octave
1267 1264
1268 Many of Octave's standard functions are distributed as function files. 1265 Many of Octave's standard functions are distributed as function files.