Command
continue
Purpose
Skips the rest of the commands in the inner-most do-done block.
Aliases
continue, cnt
Syntax
continue [<options>] [ <code> [ <message>] ]
Options
-o Write the <message>, if any, to stream output instead of stream error.
If a <message> is specified, it is written to stream error without this option.
With this option, the <message> is written to stream output instead.
Arguments
<code> An integer value. This code is called continue code and if specified, is assigned to
the system variable $continuecode.
This argument can be specified using either a constant, variable, function call,
inline command, or an expression consisting of any of these.
In all cases, the argument must result in a value of type integer.
<message> A string value. This string is written to either stream error or
stream output depending on whether option -o is specified.
This argument can be specified using either a constant, variable, function call,
inline command, or an expression consisting of any of these.
In all cases, the argument must result in a value of type string. If a string
constant is used, it must be enclosed in double quotes.
<message> can be specified only if <code> is specified.
Stream Input
Ignored.
Stream Output
If the -o option is specified, and <message> is specified, a message in the following format
is written to stream output.
continue <code>: <message>
Stream Error
Any errors encountered are written here.
In addition, if the -o option is not specified, and <message> is specified,
a message in the following format is written to stream error.
continue <code>: <message>
Such messages to stream error can be used for tracing execution of a script.
Description
do...done is a programming construct that allows grouping of commands into what is
known as a command block, or a do block, or do-done block.
If a continue command is encountered within a do-done block, all the commands within
that block after the continue command will skip execution. Execution will resume when
the done command is encountered. The following is a simple example.
var integer i
while ($i <= 10)
do
set $i=$i+1
if ($i > 5)
continue
endif
echo ($i*$i)
done
This will print squares of numbers from 1 to 5. When the value of integer variable $i
exceeds 5, the echo command will be skipped.
It is important to note that the continue command continues only the inner-most
do-done block. Also, the continue command does not skip the while loop itself.
The while loop keeps executing until the while condition becomes untrue.
When a continue command is executed, and <code> is specified, the value of <code> is
assigned to the system variable $continuecode. This system variable always contains the
<code> from the last executed continue command. If no continue command has executed
yet, or if the last executed continue command did not specify <code>, this value is 0.
The value of $continuecode can be used later for determining which continue command
executed.
Restrictions
This command is not allowed outside a do-done block.
Valid Examples
var string list, file
lf -n "*.txt" "C:/test" > $list
while ($list <> "")
do
lex "1" $list > $file
fdinfo $file > null
if ($fctime < "2010")
continue
endif
# Reset file modification time to current time.
fdset -m $file
done
This code lists all text files in directory "C:/test" (if it exists). It then
skips ('continues') those files that were created before year "2010". For the
remaining files, it resets the file modification time to current time.
Invalid Examples
Consider the following code.
var string list, file
lf -n "*.txt" "C:/test" > $list
while ($list <> "")
do
lex "1" $list > $file
fdinfo $file > null
if ($fctime < "2010")
do
continue
done
endif
# Reset file modification time to current time.
fdset -m $file
done
This code is similar to the code above, except there is an additional do-done block
inside the if command. When the continue command is executed, it only skips the
inner do-done block. As a results file modification time of ALL files will be reset
to current time.
See Also
do
break
exit
systemvar
|
© 2008-2013, 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.
|