Arbortext Command Language > Commands > if
  
if
if (condition ) {cmds} [ else if (condition) {cmds} …] [ else { cmds}]
This command executes the commands listed only if the given condition is true. else if clauses let you specify alternative commands to be executed when alternate conditions are true. The else clause specifies a course of action to be taken if none of the conditions tested for are true. You may specify any number of else if clauses, but only one else clause.
cmds is a list of one or more commands. The list must be enclosed in curly braces. condition is a logical expression describing the case in which these commands are to be executed.
Examples
if ($doctype=="book") {
dft glossword font-change;
ms -global glossword TypeStyle=bold
}
if ( $answer == "yes" ) {
# do something
}
else if ($answer == "no") {
# do something else
}
else {
# try again
}
if (! access($file,"w") {
message "can't write file $file"
}
else {
write -buffer buf1 $file
}
copy_mark
if ($status !=0) {
message "You must select something first”
}
Related Topics
If, while, for, switch
Functions as expressions and commands
Command variables
Using expressions
Logical expressions
while command