Command
if, else, endif
Purpose
Directs execution or non-execution of commands or command blocks.
Aliases
if, else, endif
Syntax
if <condition>
<line1>
[
else
<line2>
]
endif
Options
None.
Arguments
<condition> An expression resulting in a bool constant.
<line1> The line to execute if <condition> is true.
<line2> The line to execute if <condition> is false.
Both <line1> and <line2> can have one command or a block of commands enclosed within do...done.
Stream Input
Ignored.
Stream Output
None.
Stream Error
Any errors are listed here.
Description
if...else...endif is a programming construct that allows the user to selectively execute, or not execute,
commands or command blocks.
<condition> is evaluated at runtime, and not when the command is first entered.
(Since the if, and any other command, can be inside another programming construct, function, script etc.,
its run-time value may not be necessarily the same as its parse-time value.)
Nesting of all programming constructs (while, if...else...endif, do...done, function, etc.) is allowed.
There is no limit on how many levels of nesting can be done.
<condition> can contain AND, OR, and NOT bool operators. It is recommended that you use parentheses when
using these operators. There is no limit on how many, or how many levels of, parentheses can be used.
Restrictions
Stream redirection is not allowed on if, else and endif commands. However, commands within <line1> and <line2>,
and within do-done command-blocks used in place of <line1> or <line2>, can contain their own stream redirection.
Valid Examples
var int i
... # Value of i is assigned.
if ($i>0)
echo "i is positive"
endif
Will print 'i is positive' if i is positive.
Invalid Examples
var int i
...
if ($i)
echo "i is non-zero"
endif
Will produce error. The expression ($i) does not evaluate to a bool value. If the intention is to check
if i is non-zero, then that condition may be specified in one of the following ways.
if (makebool(int($i)))
or
if ($i<>0)
See Also
do
while
makebool
|
© 2008-2012, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com.
Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.
|