![]() www.fireflysoftware.com |
Piping Explained |
|
|
|
||
|
|
What is piping? In Windows, any console program whose input can be redirected, using the input redirection operator, "<" to originate from a source other than the keyboard and whose output can be redirected, using the output redirection operator, ">" to go to a destination other than the console display is technically known as a filter. You are probably already familiar with the very useful filter called SORT. It is often employed from the command prompt as follows:
This sorts the text in UNSORTED.TXT and outputs the resulting text to the console display. This is great if you only need one filter to process your text... Following is a more capable form of the above example:
Here, the piping operator, "|" effectively connects the output of the TYPE command with the input of the SORT filter, creating what is known as a pipe. This example demonstrates a simple one-filter pipe that is functionally identical to the first example. Pipes can be created containing any number of filters. For example, the MORE filter could be added to our pipe to pause each output screen of sorted text:
In the above examples output is being sent to the console display. A pipe's output can also be sent to a file using the output redirection operator, ">" as shown here:
Here, SORT takes it's input from UNSORTED.TXT, sorts it and writes it to the file, SORTED.TXT. If the file, SORTED.TXT already exists, it gets overwritten with the new data. If you merely want to append the new data to a file that already exists, use the append redirection operator ">>" instead as shown here:
Here, the same is accomplished using the piping operator:
TEXTools Pipes The above is generally how pipes and filters work at the command prompt. Text originates from some source, goes through one or more filters and is output either to the console display or redirected to a file. TEXTools takes this same paradigm of pipes and filters and simply wraps it in a Windows user interface in which the pipe is transposed from one that is laid out horizontally (as those depicted above) to one that is vertical. A TEXTools pipe is thus presented to the user as multiple lines, each one representing a single filter in the pipe. A pipe that parses the words in the input text, pads each one to equal lengths and then joins them into 3 columns would therefore be formatted onto three lines as follows:
This transposing of a pipe in the GUI version of TEXTools however does not occur in TEXTools Command Line, (TCL), which, as its name implies, is used at the command line or command prompt. In TCL, the above pipe would still be presented horizontally as shown by the following example:
|
|
|
Copyright © 2005 Firefly Software |
||