PRODUCT |

|

|
|
|

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

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

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

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

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

|
|
|
|
|
Help Page - len
( 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. )
|
|
|
Command
len
Purpose
Editor - Line enumerator or counter
Aliases
lineenumerator, lineenum, len
Syntax
len [ <options> ] <input_string>
Options
-e Count empty lines. Without this option, empty lines are not
considered.
-c Case insensitive. Case will be ignored when considering separator
characters.
Arguments
<input_string>
The input string on which this command will operate. It
can be specified as a str constant or str variable or an
expression resulting in a str value.
If a str constant is used, we highly recommend using
double quotes around it, such as "John Doe".
Without the double quotes, the spaces in the input string
will produce errors or erroneous output.
Stream Input
Stream input is ignored.
Stream Output
The number of lines found are written here.
Stream Error
Any errors are listed here.
Description
The command enumerates (or counts) lines in the <input_string> and
writes the count to the stream output or redirected stream output.
The command CAN ALSO BE USED WITH FILES. Simply read in the contents
of the file using the repro command into a str variable, then use that
str variable as <input_string>.
The command uses system variable $lsep. This variable lists line separators.
Each character in $lsep is assumed to end a line. See help page for systemvar
for details on this system variable.
You are free to change the values of any system variables. It is, however, highly
recommended that you restore their values to their previous values. This can be
done as follows.
# Save previous value.
var str saved_lsep
set $saved_lsep = $lsep
set $lsep = < new_value >
...
< DO_your_stuff >
...
# Restore value
set $lsep = $saved_lsep
System variables are used by many commands, and incorrect setting of their values
may affect the operation of these commands.
Restrictions
None.
Valid Examples
Assume that you want to count lines in a file myfile.js.
var str content
repro myfile.js >$content
len -e $content
The above code will produce the number of all lines (including empty lines)
in file myfile.js.
To count just the non-empty lines, do NOT use the -e option, as follows.
len $content
Invalid Examples
len "myfile.js"
Will produce 1. That's because myfile.js will be taken verbatim as
<input_string>, and there is only one line in that string.
len { repro "myfile.js" }
Will also produce erroneous results. The inline command { repro "myfile.js" }
will execute and bring out its output as part of the len command.
The len comand will then consider the first word of the output as <input_string>.
So, if the first line of myfile.js is empty, since we did not specify -e option,
the output of the len command will be 0. If the first line of myfile.js is not
an empty line, the output of the len command will be 1.
To correctly count the number of lines in myfile.js, use the code listed
above under Valid Examples.
See Also
systemvar
var
echo
escape
lex
lin
lap
lal
sen
wen
chen
|
|
|
© 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.
|
|