System Feature
edit
Purpose
Explains the matrix of automated editors available.
Aliases
None
Syntax
See syntax for individual editors.
Options
See help pages on individual editors.
Arguments
See below.
Stream Input
See help pages on individual editors.
Stream Output
See help pages on individual editors.
Stream Error
See help pages on individual editors.
Description
A powerful matrix of editors are available in biterScripting.
The editors are divided according to
- the TARGETs they seek or edit
- the editor OPERATION the perform.
We will explain each.
TARGET
----------
biterScripting editors can seek, find, count and perform various operations on
targets of various kinds. The folloing target types are available.
Character
A single character. Can be a printable, non-printable, or
special character. Editor commands that operate on characters
have the prefix of "ch".
Word
A collection of characters. Words are separated by word-separator characters,
which typically are space, tab, comma, etc. Editor commands that
operate on words have the prfix of "w". These commands use a special
system variable $wsep, which contains the list of word separator characters.
Any character in the value of $wsep is assumed to end one word and start
another. A default value is assigned to $wsep at startup. You can change this value
to make word editors behave according to your requirements.
Line
A collection of characters and words. Line are separated by line-separator characters,
which typically is newline ("\n"). Editor commands that
operate on lines have the prfix of "l". These commands use a special
system variable $lsep, which contains the list of line separator characters.
Any character in the value of $lsep is assumed to end one line and start
another. A default value is assigned to $lsep at startup. You can change this value
to make line editors behave according to your requirements.
String
A collection of characters, words and lines. Strings do not have any separators.
They are identified with their values such as "abc", "\n", etc. Editor commands that
operate on strings have the prfix of "s".
OPERATION
------------
biterScripting editors can perform the following operations on each of the targets.
Enumerate
Enumerate or count. The enumerator editors have the suffix of "en".
Find (Extract)
Delete or Remove (Extract)
Find and Delete operations are combined into EXTRACT operation.
See later on how to use the same Extractor editor to do both of these
operations. The extractor editors have the suffix of "ex".
Insert
The inserter editors have the suffix of "in".
Append
The appender editors have the suffix of "ap".
Alter
Alter, change, replace or modify. The alterer editors have the suffix of "al".
COMMAND NAMES
--------------
Using the prefixes and suffixes described above, we will now draw a table (matrix) of
available editor commands.
OPERATION TARGET
--------------- ------------------------------------------------------------------------
Character Word Line String
(ch) (w) (l) (s)
--------------- --------------- --------------- ---------------
Enumerate (en) chen wen len sen
Extract (ex) chex wex lex stex
Insert (in) chin win lin sin
Append (ap) chap wap lap sap
Alter (al) chal wal lal sal
Arguments
The following are commonly used arguments.
<input_string>
This is the input on which commands will operate. Note that this input
is NOT passed through stream input (all editor commands ignore stream input -
this is done for a specific reason, which will become apparent a little later).
Rather, <input_string> is passed throuh an argument on the command line.
<input_string> can be a constant, a variable, an expression, a function call,
an inline command (do you see the benefit of passing <input_string> through arguments
instead of stream input now ?), or any combination of these, together forming
a valid expression (resulting in str value).
<input_string> can be vary large, and biterScripting str variables are able to handle
any size of data. For example you can read an entire file, or all pages on your
web site into one str variable, and pass that variable as <input_string> argument to
any of the editor commands.
<search_string>
This is also called search target. This is used by string editors. It is
enclsoed within carets (^) (also known as cut-here symbols).
For example, "^Copyright^" will indicate that the command is to look for the
target "Copyright". <search_string> can be a constant, a variable, an expression,
a function call, an inline command or any combination of these, together forming
a valid expression (resulting in str value).
To achieve more power from string editors, <search_string> can be a Regular Expression.
If the -r option is specified in string editor commands, <search_string> will be
treated as a Regular Expression. See the help page on RE (Regular Expression) for
the syntax of Regular Expressions.
<n> The instance number. Instance numbers are counted from 1. <n> can be any number from
1 onwards. It can also be "l" (Lower case Ell - L), indicating last instance. For example,
"^Copyright^2" will mean second (2nd) instance of string target "Copyright". <n> can
be a constant, a variable, an expression, a function call, an inline command or any
combination of these, together forming a valid expression (resulting in str value).
<insert_string>, <append_string> or <alter_string>
One of these arguments is used by the inserter, appender and alterer editors.
These represent the string to insert before, append after, or replace in place of,
the <serach_target>. These also can be a constant, a variable, an expression,
a function call, an inline command or any combination of these, together forming a
valid expression (resulting in str value).
<start_bounder>
<end_bounder>
These bounder further narrow down the target of operation. They can be either
absent, or open bracket ([), or close bracket (]). Open bracket indicates
"starting at". Close bracket indicates "ending at". For example,
"^Copyright^3]" would indicate that the operation target is from start of
the <input_string> upto (and including) the third (3rd) instance of string
"Copyright". Similarly, "^Copyright^3[" would indicate that the operation target
starts after (but not including) third (3rd) instance of string "Copyright" and goes
on till the end of <input_string>. See the help page on an individual editor command,
which will show all combination of these bounders and explain how that command interprets
those combinations.
All of the <input_string> <search_string>, <n>, <insert_string>, <append_string>, <alter_string>,
<start_bounder> and <end_bounder> can be passed using a constant, a variable, an expression, a function call,
an inline command or any combination of these, together forming a valid expression (resulting in str value).
THIS MEANS THAT THESE ARGUMENTS ARE EVALUATED WHEN THE COMMAND IS ACTUALLY EXECUTED (and NOT when the
command is parsed), WHICH PROVIDES THE MAXIMUM FLEXIBILITY AND THE HIGHEST BENEFIT OF EDITOR COMMANDS.
This is the primary reason why all of these are supplied through arguments and NOT through stream input.
Special Characters
Many characters have special significance in editor commands. As we saw above, the caret (^)
(also called the cut-here symbol) indicates the start and end of a <search_string>, The
open ([) and close (]) brackets indicate the bounders. Similarly, Regular Expressions
use special characters to indicate special significance. If your <search_string> contains
these symbols, you do not wish them to be treated with special significance, escape them
with a backslash, such as, \^, \[, \], etc.
Restrictions
Valid Examples
See help pages for individual editor commands.
Invalid Examples
See help pages for individual editor commands.
See Also
escape
RE
chen
wen
len
sen
chex
wex
lex
stex
chin
win
lin
sin
chap
wap
lap
sap
chal
wal
lal
sal
|