PRODUCT |

|

|
|
|

|
|
|
|
|
|
|
|
|
FAQ |
|
|

|
|
|
|
|
|
|
|
|
|
LEARN SCRIPTING |
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SAMPLE SCRIPTS |
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HELP / DOCUMENTATION |
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
Help Page - inline
( Some help pages may not display correctly in html because those help pages may have sample code in them, part of which may be mis-interpreted as html tags.
All help pages, including this help page, are available in biterScripting with the help command. )
|
|
|
System Feature
Inline Command
Purpose
Executes a command as part of another command.
Syntax
{ <command> }
Description
An inline command is a command that is embedded within another command. Inline
command is enclosed within braces (also called curly brackets) {}.
An inline command is executed at run time and its output is substituted in place of
the { <command> } on the current command line. The current command is executed then.
Although, we use the singular word <command> to describe inline syntax,
multiple commands can be enclosed within the {} using either pipes or semicolons.
Furthermore, any combination of function calls, expressions, calls to scripts,
can be enclosed within the {}.
Inline commands can be crucial in redirecting streams. We will explain it
by way of an example. Consider the following sample script.
# Assume that we have a few .jsp files. We are
# inserting Copyright notice in each of them.
# Collect a list of .jsp files in a variable.
var str fileList
lf -rn "*.jsp" "C:/myproject" > $fileList
while ($fileList <> "")
do
# Get the next file from the file list.
var str file
set $file = { lex "1" $fileList }
# Read the content of $file into a variable.
var str content
repro $file > $content
# Insert copyright before the first line.
lin -e "1" "Copyright (c) 2008, My Company\n" $content >null
# We don't want to see the output of the above lin command,
# we want the $content itself to be modified.
# Write the modified content back to file.
echo $content > $file # <======== LOOK AT THIS REDIRECTION
done
Look at the line that contains > $file. The intention here
is to read files, insert copyright notice, save files, one by one.
However, instead of writing to a file whose name is in $file, the output
of the echo command is being written to the variable $file.
This defeats our purpose.
To alleviate this problem, the redirection should be specified as follows
> { echo $file }
This inline command substitutes the actual file name in place
of the inline command. As a result, the output of the echo
command will now be correctly written to the file.
Inline commands can be used in all input, output and error stream
redirections.
Restrictions
Inline command(s) can not be nested.
Valid Examples
repro "mypage.aspx" > $content
echo "Number of lines in file: " { len $content }
The above will show the count of lines in the file mypage.aspx.
repro { lf -rn "*.txt" }
The above will list contents of all .txt files in the current directory
and any subdirectories.
Invalid Examples
wen { repro { lf -rn "*.txt" } }
The intention above is to first list all .txt files, then reproduce their contents,
then count the words. This is an example of invalid nesting of inline commands. The
intention, however, can be achieved using the following.
var str $content
repro { lf -rn "*.txt" } > $content
wen $content
See Also
var
pipe
stream
input
output
error
|
|
|
© 2008-2010, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, 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.
|
|