Changes between Version 7 and Version 8 of code/doc/CommandExecutor
- Timestamp:
- Apr 12, 2017, 10:41:41 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/CommandExecutor
v7 v8 1 1 = !CommandExecutor = 2 [[TracNav(TracNav/TOC_Development)]]3 2 [[TOC]] 4 3 … … 16 15 '''execute('''''string''''')''' parses the string and searches a [wiki:ConsoleCommand] with the given name. Given arguments (separated by spaces) are used to execute the !ConsoleCommand. 17 16 18 ''string'' has to be a complete !ConsoleCommand (complete in the sense that the command exists and all needed arguments are given), otherwise the !CommandExecutor returns false and sends an [wiki: Debugerror message] to the output.17 ''string'' has to be a complete !ConsoleCommand (complete in the sense that the command exists and all needed arguments are given), otherwise the !CommandExecutor returns false and sends an [wiki:Output error message] to the output. 19 18 20 19 * Example 1: … … 28 27 CommandExecutor::execute("MyClass myfunction 0.1 0.2 0.3"); 29 28 }}} 30 This is equal to ''MyClass::myfunction(0.1, 0.2, 0.3)'' provided that the function "myfunction" of the class " MyClass" was declared as a !ConsoleCommand.29 This is equal to ''MyClass::myfunction(0.1, 0.2, 0.3)'' provided that the function "myfunction" of the class "!MyClass" was declared as a !ConsoleCommand. 31 30 32 31 The execute function optionally takes a second argument: '''execute('''''string, bUseTcl''''')'''. If ''bUseTcl'' is set to true (this is the default!) a command is first passed to Tcl (see [wiki:TclBind] for more information). Tcl parses the command, executes all Tcl-related code and if it finds a !ConsoleCommand only known to Orxonox it passes the command back to CommandExecutor::execute with ''bUseTcl = false''. … … 36 35 CommandExecutor::execute("MyClass myfunction [expr 10+10]"); 37 36 }}} 38 This command will be sent to Tcl. Tcl first evaluates the subcommand within brackets ''expr 10+10'' which results ''20'' and then returns " MyClass myfunction 20" back to Orxonox where it will be executed equivalent to ''MyClass::myfunction(20)''.37 This command will be sent to Tcl. Tcl first evaluates the subcommand within brackets ''expr 10+10'' which results ''20'' and then returns "!MyClass myfunction 20" back to Orxonox where it will be executed equivalent to ''MyClass::myfunction(20)''. 39 38 40 39 === hint() ===