A space is always used to separate command arguments. If you want to have a space within a command argument, you must enclose the argument within quotes (" ") or curly braces ({ }) or escape the space with a backslash (\).
These methods are not all equivalent. The backslash has the highest priority, and only it can be used to quote any special character (even itself). Braces have the second-highest priority.
The difference between braces and quotes is that quotes can quote only spaces (and braces, see below). Consider the following examples, where the braces cause everything within them to be understood literally, but quotes allow the variable within them to be interpreted:
BTCL > set a 50 50
BTCL > set b {The value of a is $a} The value of a is $a
BTCL > set b "The value of a is $a" The value of a is 50Braces and quotes can be used to quote each other. When programming complex scripts in BTCL, it is important to remember these rules and that only the outermost quotation characters are significant.
For example:
BTCL > set b {"$a"} "$a"
BTCL > set b "{$a}" {50}Square brackets ([ ]) are used to evaluate subcommands within another command. Variable substitution within brackets does not occur until the command script is executed, so that, in the following example, the variable a is set to 5 and not 3, as would occur if the $ were evaluated first:
BTCL > set b 3 ; set a "[set b 5;echo $b]" 5An alternative way to execute subscripts is to use the eval command. The eval command takes a single argument, as opposed to brackets, which contain a script. This difference reflects the way in which BTCL handles list elements and is shown in the following example:
BTCL > set a "set b 3.4" set b 3.4
BTCL > eval $a 3.4
BTCL > [$a] Error: invalid command name "set b 3.4"The expr command is provided to evaluate mathematical expressions. Expr takes one or more arguments. If the expression is contained in one argument and contains spaces, it should be quoted. For example:
BTCL > echo 3 * $b = [expr "3 * $b"] 3 * 3.4 = 10.2Parentheses ( ) are special characters only when used in mathematical expressions, where they are used in the usual way to specify operational precedence. In BTCL the following commands are equivalent:
BTCL > set a [expr (3-1)*4] 8
BTCL > $a = (3-1)*4 8Other BTCL special characters and character combinations are used for logical and arithmetic expressions and mathematical functions.
BTCL Language access
Variables and Expressions
Control Statements
Copyright Biosym/MSI