User`s manual
Tcl commands
ModelSim Xilinx User’s Manual Tcl and ModelSim 10-245
9 If a hash character ("#") appears at a point where Tcl is expecting the first character of
the first word of a command, then the hash character and the characters that follow it,
up through the next newline, are treated as a comment and ignored. The comment
character only has significance when it appears at the beginning of a command.
10 Each character is processed exactly once by the Tcl interpreter as part of creating the
words of a command. For example, if variable substitution occurs then no further
substitutions are performed on the value of the variable; the value is inserted into the
word verbatim. If command substitution occurs then the nested command is processed
entirely by the recursive call to the Tcl interpreter; no substitutions are performed
before making the recursive call and no additional substitutions are performed on the
result of the nested script.
11 Substitutions do not affect the word boundaries of a command. For example, during
variable substitution the entire value of the variable becomes part of a single word,
even if the variable’s value contains spaces.
if command syntax
The Tcl if command executes scripts conditionally. Note that in the syntax below
the "?" indicates an optional argument.
Syntax
if expr1 ? then? body1 elseif expr2 ? then? body2 elseif ... ?else? ?bodyN?
Description
The if command evaluates expr1 as an expression. The value of the expression
must be a boolean (a numeric value, where 0 is false and anything is true, or a
string value such as true or yes for true and false or no for false); if it is true then
body1 is executed by passing it to the Tcl interpreter. Otherwise expr2 is evaluated
as an expression and if it is true then body2 is executed, and so on. If none of the
expressions evaluates to true then bodyN is executed. The then and else arguments
are optional "noise words" to make the command easier to read. There may be any
number of elseif clauses, including zero. BodyN may also be omitted as long as
else is omitted too. The return value from the command is the result of the body
script that was executed, or an empty string if none of the expressions was non-
zero and there was no bodyN.