You can use all of TextPipe Pro's powerful text-processing functions from any external programming language using TextPipe's COM interface (not available in Web or Standard editions). Using the File Menu\Export functions, you can export fully-working VBScript or JScript code to create and run a given filter.

Please see the TextPipe Pro help file (under Advanced Topics) for the latest version of this information.

A sample script is included in the TextPipe installation in the VBScript\sample.vbs file. See also our web  front-end demo (which assumes that you have TextPipe Pro installed).

Notes:

  1. When a filter is added to the filter list, a treenode variable is returned which can be ignored unless you need to create sub filters. To create sub filters you need to surround them with startSubfilters and endSubfilters commands.
  2. Values that are NOT indicated as allowed are not supported and may cause errors.

TextPipe.Application

newWindow() : TextPipe.FilterWindow Returns a new TextPipe.FilterWindow object that holds a new TextPipe filter window
minimize() Minimizes TextPipe's main window
restore() Restores TextPipe window to its previous size
hide() Hides TextPipe's window
show() Shows TextPipe's window
version() : string Returns the TextPipe version number string
findWindow( filename : string ) : TextPipe.FilterWindow Searches for an existing window that already has the given filter filename loaded, and returns it if found. If not found, it opens a new window, loads the given filter into it and returns it.
calledFrom( applicationName : string ) Sets the calling application name. When set, the File\Exit menu item changes to 'Exit and return to applicationName', and when the user tries to close TextPipe it simply hides itself. This is very handy when calling TextPipe from a third party application.
close() Attempts to close TextPipe, prompting the user to save any modified filters.
quit() Closes TextPipe WITHOUT prompting the user to save any modified filters. This function is the only way to close TextPipe after it has been made visible (even if TextPipe is made invisible again)
property visible : boolean True if the main form is visible, False if it is not. When called from COM, TextPipe's window is initially invisible. As soon as TextPipe is made visible, it locks itself in memory to prevent itself being closed by COM. The only way to close it is to call the Quit function (making it invisible does not change this)
property activeFilter : TextPipe.FilterWindow Returns the top-most filter window. If none, returns nil.
property installationFolder : string Returns the folder where textpipe.exe file is located, with a trailing backslash. This can be used to find the correct local path to load a pre-defined filter from.
property Application : TextPipe.Application Returns the Application object
property Parent : TextPipe.Application Returns the Application object
property currentDirectory : string Gets or sets the current directory.

TextPipe.FilterWindow

Open and closing files
openFilter( filename : string ) Opens a filter with the specified filename
appendFilter( filename : string ) Appends the new filter to the current filter
saveFilter( filename : string ) Saves the current filter with the given filename
close() Closes the filter window
closeWithoutSave() Same as close but closes the window without prompting even if the filter has been changed
property filterChanged : boolean Read/Write. True if the current filter has been saved, False if it has been changed
property scratchPad : string Read/Write. The scratch pad text
property trialInput : string Read/Write. The trial input text
property comments : string Read/Write. The comments tab text.
property isRunning : boolean Read Only. True if the filter is currently running.
Filters
Before any filters are added or any Logging, Input or Output settings are changed, you must call

startFilters()

first, and then call

endFilters()

when you have finished adding or changing. These function turn off the GUI, making adding filters much faster. They also prevent the GUI settings from overwriting the settings you make.

To create sub filters, you must surround each set of sub filters like this:

startSubfilters()

...define filters here...

endSubfilters()

clearAllFilters() Removes all filters from the filter list
moveCursorToEnd() Moves the cursor in the treeview to the end of the list. By default, when a filter is loaded the cursor is on the Input Filter. If you want to add additional filters you generally will want to move the cursor to the end of the filter list first.
makeSubfilterOf( parent : treenode, child : treenode ) This function has been superseded by the startSubfilters and endSubfilters commands.

Moves the child filter so that it becomes the last child sub filters of the parent filter. You must determine if this action is legal or not yourself - TextPipe does no error checking.

addSelectionFilter( type : integer, locateMethod : integer, param1 : integer, param2 : integer, moveTo : integer, processIndividually : boolean, excludeDelimiter : boolean, excludeQuotes : boolean ) : treenode Adds a filter from the Restriction menu. Note that Restriction filters almost always require sub filters in order to have any effect.

Type - the type of filter to add

0 Delete column
1 Restrict lines
2 Restrict columns
3 Not used
4 Restrict CSV fields
5 Restrict tab-delimited fields
6 Remove lines
7 Remove CSV fields
8 Remove Tab-delimited fields
9 Move columns
10 Move CSV columns
11 Move Tab-delimited columns
12 Copy columns
13 Copy CSV columns
14 Copy Tab-delimited columns

Locate Method - how to determine which areas to affect

0 Restrict %d .. %d
1 Restrict %1:d starting at %0:d
2 Restrict %1:d starting at END - %0:d
3 Restrict %d .. END - %d
4 Restrict END - %d .. END - %d

param1, param2 - the required integer values for the locate method

moveTo : integer - where to move or copy the columns or fields to. Default 1.

processIndividually - whether or not to apply sub filters to each CSV or Tab field individually, or to the fields as one string value. Default false.

excludeDelimiter - whether or not to include the comma or Tab field delimiter when passing the field to the sub filter. Default true.

excludeQuotes - whether or not to include the CSV quotes that may surround the field when passing the field to the sub filter. Default true.

addGrepFilter( type : integer, pattern : string, includeLineNumbers : boolean, includeFilename : boolean, ignoreCase : boolean, countMatches : boolean, patternType : integer ) : treenode Adds a Grep type line based filter.

type

0 Restrict lines matching
1 Restrict lines NOT matching
2 Extract
3 Retain matching lines
4 Retain non-matching lines
5 Remove matching lines
6 Remove non-matching lines

pattern - the pattern to match

includeLineNumbers - true to include the line number where the pattern was found, default False

includeFilename - true to include the filename where the pattern was found, default False

ignoreCase - ignore case when matching the pattern, default True

countMatches - true to only output a count of the number of matches, default False

patternType

0 Perl pattern
1 Egrep pattern
2 Brief pattern
3 MS Word pattern
4 EasyPattern

addSplitFilter( type : integer, splitSize : integer, splitChar : string, splitCharPos : integer, splitCharCount : integer, splitLines : integer, splitFilename : string ) : treenode Adds a split type filter

type

0 Split at a given size
1 Split at a given character
2 Split at a given number of lines

splitSize - the size file to split at

splitChar - the character to split at

splitCharPos -

0 Split before the character (it goes into the next file)
1 Split after the character (it remains in the first file)
2 Split on top of the character (remove it)

SplitCharCount - the number of times to see SplitChar before splitting

SplitLines - split after a given number of lines

SplitFilename - the name to give to each output split file

addMergeFilter( type : integer, filename : string ) : treenode Adds a merge type filter

type

0 Merge into filename
1 Retain lines found in filename
2 Remove lines found in filename
3 Link filter filename

filename - the filename to use

addHeadTailFilter( includeOrExclude : boolean, linesOrBytes : integer, startOrEnd : boolean, count : boolean, ) : treeNode Adds a Head/Tail type filter

includeOrExclude - whether to include or exclude the text, False for Include, True for Exclude

linesOrBytes - measure in terms of lines or bytes, False for Lines, True for Bytes

startOrEnd - measure from the start or end of the file, False for Start, True for End

Count - the count of lines or bytes to include or exclude

addRunFilter( commandLine : string, inputFilename : string, outputFilename : string ) : treeNode Adds a Run External Program filter

commandLine - the command line of the program to run. Should include double quotes around long filenames, and also usually includes the input and output filename.

inputFilename - the filename that TextPipe should read from after the External Program writes to it.

outputFilename - the filename that  TextPipe should write to for the External Program to read in.

addSortFilter( type : integer, reverse : boolean, removeDuplicates : boolean, startColumn : integer, length : integer ) : treenode Adds a sort type filter

type - the sort type

0 ANSI sort (case insensitive)
1 ANSI sort (case sensitive)
2 ASCII sort (case insensitive)
3 ASCII sort (case sensitive)
4 Numeric sort
5 Sort by length of line
6 Sort by date and time
7 Sort by date
8 Sort by time

reverse - whether to reverse the normal sort order, when set to True the order is Descending, default false

removeDuplicates - whether to remove duplicate values or not, default true

startColumn - the column to start comparisons from

length - the length of the comparison

addDuplicatesFilter( type : integer, ignoreCase : boolean, startColumn : integer, length : integer ) : treenode Adds a Show or Remove Duplicates filter

type -

0 Remove duplicate lines
1 Show duplicate lines

ignoreCase - whether to ignore case during comparisons or not

startColumn - the starting column for the comparison

length - the length of the comparison

addReplaceFilter( searchStr : string, replaceStr : string, type : integer, matchCase : boolean, wholeWord : boolean, caseSensReplace : boolean, promptOnReplace : boolean, extract : boolean, firstOnly : boolean, skipPromptIdentical : boolean ) : treenode Adds a search and replace (find and replace) filter. See also the setPerl, setEditDistance and setBufferSize functions (below) for setting additional parameters.

searchStr - the string to search for

replaceStr - the string to replace it with

type - the find type:

0 Replace
1 Pattern (old style)
2 Sounds like
3 Edit distance
4 Perl pattern
5 Brief pattern
6 Word pattern
7 EasyPattern

matchCase - Matches case when set to True, ignores case when set to false (default)

wholeWord - Matches whole words only when set to True, default false

caseSensReplace - Replaces with matching case when set to True, default false

promptOnReplace - Prompts before replacing when set to True, default false

extract - when True, all non-matching text is discarded, default false

firstOnly - when True, only replace the first occurrence, default False

skipPromptIdentical - when True, don't bother prompting if the replacement text is identical to the original.

addReplaceListFilter( filename : string, type : integer, matchCase : boolean, wholeWord : boolean, caseSensReplace : boolean, promptOnReplace : boolean, firstOnly : boolean, skipPromptIdentical : boolean ) : treenode Adds a search and replace list filter. See also the setPerl, setEditDistance and setBufferSize functions (below) for setting additional parameters.

filename - the file to load search/replace pairs from

Other options - as above.

setEditDistance( threshold : integer ) : boolean Sets the edit distance threshold for the immediately preceding search/replace filter. Default 2.
setBufferSize( bufferSize : integer ) : boolean Sets the buffer size for the immediately preceding search/replace filter. Default 4096.
setPerl( bufferSize : integer, greedy : boolean, allowComments : boolean, dotMatchesNewLines : boolean ) : boolean Sets the perl matching options for the immediately preceding search/replace filter.

bufferSize - the maximum buffer size to use for matches. Any match must fit into this buffer, so if you want to match larger pieces of text, increase the size of this buffer to suit. Default 4096.

greedy - if the pattern finds the longest match (greedy) or the shortest match. Default false.

allowComments - allow comments in the perl pattern. Default false.

dotMatchesNewLines - allow the '.' operator to match all characters, including new lines. Default true.

addNumberFilter( type : integer, value : integer ) : treenode Adds a Number-type filter.

type - the type of filter to add

0 Convert Tabs to %d spaces
1 Convert %d spaces to Tabs
2 Word wrap (column width %d)
3 Pad to width of %d
4 Centre in width of %d
5 Right justify in width of %d
6 Restrict CSV field %d
7 Restrict tab-delimited field %d
8 Truncate to width %d
9 Force to width %d
10 Repeat file %d times

Value - the numeric value to use

addInsertFilter( insertPos : integer, insertString : string ) : treenode Adds an insert column-type filter.

insertPos - the position to insert the string

insertString - the string to insert

addDatabaseFilter( connectionStr : string, mode : integer, fieldDelimiter : string, textQualifier : string, generateHeader : boolean, insertTable : string, timeout : integer ) : treenode Adds a database-type filter.

connectionStr - the database connection string.

mode

0 Delimited output
1 Fixed width
2 XML
3 Insert script

fieldDelimiter - the string to use between columns

textQualifier - the string to use around string column values

generateHeader - generates header information when True

insertTable - the name of the insert table

timeout - SQL command timeout in seconds, default 30

addMapFilter( filename : string ) : treenode Adds a single byte map-type filter from a file

filename - the filename containing the map

See also prepareMapFilter

prepareMapFilter() : treenode

setMap( characterIndex : integer, outputString : string )
setMap( characterIndex : integer, outputString : string )
setMap( characterIndex : integer, outputString : string )
...

Adds a single byte map-type filter and allows it to be configured by the following statements

See also addMapFilter

prepareUnicodeMapFilter( unenteredValue : integer, replaceWith : string ) : treenode

setUnicodeMap2( startRange, endRange, outputString : string )
setUnicodeMap( characterIndex : integer, outputString : string )
setUnicodeMap( characterIndex : integer, outputString : string )
setUnicodeMap( characterIndex : integer, outputString : string )
...

Adds a Unicode map-type filter and allows it to be configured by the following setUnicodeMap or setUnicodeMap2 statements.

unenteredValue:

  • 0 - Pass through unchanged
  • 1 - Pass to subfilter
  • 2 - Replace with value (use next option to specify it)
  • 3 - Remove

Replace with:

The string to replace it with, if the Replace Type is 2.

addEOLfilter( inputLineFeeds : integer, fixedLength : integer, outputLineFeeds : integer, newLineFeed : string, removeBadEOLs : boolean ) : treenode Adds an EOL (end of line) conversion filter

inputLineFeeds - the type of incoming line feeds

0 Unix
1 Mac
2 DOS
3 Auto
4 Fixed (use the fixedLength parameter to specify the length)

fixedLength - the length of fixedLength input files when option #4 is chosen above.

outputLineFeeds - the type of outgoing line feeds

0 Unix
1 Mac
2 DOS
3 None
4 String (use the newLineFeed parameter to specify the new string)

newLineFeed - the new line feed string on output when option #4 is chosen.

removeBadEOLs - whether to remove bad EOLs or not

addSimpleFilter( type : integer ) : treenode Adds a simple filter type, requiring no special parameters.

type - the type of filter to add.

1 Convert ASCII to EBCDIC
2 Convert EBCDIC to ASCII
3 Convert ANSI to OEM
4 Convert OEM to ANSI
5 Convert to UPPERCASE
6 Convert to lowercase
7 Convert to Title Case
8 Convert to Sentence Case
9 Convert to tOGGLE cASE
10 Remove blank lines
11 Remove blanks from End of Line
12 Remove blanks from Start of Line
13 Remove binary characters
14 Remove ANSI codes
15 Convert IBM drawing characters
16 Remove HTML and SGML
17 Remove backspaces
18 Resolve backspaces
19 Remove multiple whitespace
20 UUEncode
21 Hex Encode
22 Hex Decode
23 MIME Encode (Base 64)
24 MIME Decode (Base 64)
25 MIME Encode (Quoted printable)
26 MIME Decode (Quoted printable)
27 UUDecode
28 Extract email addresses
29 Unscramble (ROT13)
30 Hex dump
32 XXEncode
33 XXDecode
34 Reverse line order
35 Remove email headers
36 Decimal dump
37 HTTP Encode
38 HTTP Decode
39 Randomize lines
40 Create word list
41 Reverse each line
42 Convert to RanDOm case
43 Extract URLs
44 ANSI to Unicode
45 Unicode to ANSI
46 Display debug window
47 Word concordance
48 Delete all
49 Restrict to each line in turn
50 Convert CSV to Tab-delimited
51 Convert CSV to XML' )
52 Convert Tab-delimited to CSV
53 Convert Tab-delimited to XML
54 Convert CSV (with column headers) to XML
55 Convert Tab-delimited (with column headers) to XML
 

addStringFilter( type : integer, str : string ) : treenode

addStringFilterFile( type : integer, filename : string ) : treenode

Adds a string-type filter.

type - the type of filter to add

0 Add left margin
1 Add header
2 Add footer
3 Add right margin
4 Remove lines
5 Retain lines
6 Remove lines matching perl pattern
7 Retain lines matching perl pattern
8 Add text side by side
9 Add repeating text side by side

str - the string to use

filename - the filename to use

addLineNumberFilter( startNumber : integer, increment : integer, skipBlankIncrement : boolean, dontNumberBlank : boolean, numberFormat : string ) : treenode Adds a Line Number filter

startNumber - the starting line number

increment - the amount to add for each new line number

skipBlankIncrement  - don't increase the line number for blank lines

dontNumberBlank - don't put a line number on blank lines

numberFormat - the format to use for the line number

addScriptFilter( language : string, script : string, timeout : integer ) : treenode Adds an ActiveX script filter

language - the language of the script

script - the code

timeout - the command timeout in seconds, default 30

addCommentFilter( comment : string ) : treenode Adds a comment type filter

comment - the comment.

addMathsFilter( operation : integer; operand : integer ) : treenode Adds a maths type filter

operation - the operation to perform

0 +
1 -
2 *
3 div (the remainder is ignored)
4 mod (the remainder after division)
5 xor
6 and
7 or
8 not
9 shift left (0 inserted)
10 shift right (0 inserted)
11 rotate left
12 rotate right

operand - the operand to use

Output Filter
property outputMode : integer Read/Write. Sets the output mode:

0 Output to clipboard (all files are joined together)
1 Output to files
2 Output merged (joined) to a single file

property outputTestMode : boolean Read/Write. Sets the output filter test mode. True turns test mode on, default False.
property outputFolder : string Read/Write. Sets the output filter folder.
property outputRetainDate : boolean Read/Write. Sets the output filter retain date setting. True turns on the retain date setting, default False.
property outputMergeFile : string Read/Write. Sets the output filter to merge data to a single file, using the given filename.
property outputExtension : string Read/Write. Sets the output filter extension.
property outputAppend : boolean Read/Write. Sets append mode when True, default False.
property outputOnlyOutputChangedFiles : boolean Read/Write. Only outputs files that have actually changed, default True.
property outputKeepStructure : boolean Read/Write. When used in conjunction with outputFolder, determines if the original folder structure is retained, default False.
addSecondaryOutputFilter( mode : integer, testMode : boolean, retainDate : boolean, append : boolean, function onlyOutputChangedFiles : boolean, folder : string, extension : string, keepStructure : boolean, mergeFilename : string ) : treenode Adds a secondary output filter, usually used for splitting some lines or records to a new file. All parameters are as above for a normal Output filter.
property outputOpenOutputOnCompletion : boolean Opens each output file in its associated program on completion.
property outputRemoveEmpty : boolean Removes empty (zero-byte) output files - useful in conjunction with the Split Files filter
Input Filter
property InputMode : integer Read/Write. Sets the input mode:

0 Input from clipboard
1 Input from files (default). You can add files using the addFile function.
2 Input from Trial Run area. You can set the Trial Run text using the trialInput property
3 Input from random file generator. You can set the

property inputBinaryFiles : integer Read/Write. Controls how binary files are handled

value (default 0)

0 Binary files are processed
1 Binary files are skipped
2 Binary files are confirmed before processing

property InputBinarySampleSize : integer Read/Write. Default 100. Controls the binary sample size for Input files
property InputPromptOnEach : boolean Read/Write. Default False. Controls whether to prompt before processing each file.
property InputPromptOnReadOnly : boolean Read/Write. Default False. Controls whether to prompt before processing each read only file.
property InputDeleteFiles : boolean Read/Write. Default False. Controls if input files are deleted after processing. Use with caution!
property inputRandom : integer Read/Write. Sets the input to come from a randomly generated file of size size, default 1024
Logging functions
property logEnabled : boolean Read/Write. When True, logging is on, default False
property logFilename : string Read/Write. The file to log data to
property logAppend : boolean Read/Write. When True, logging appends to the existing file
property logThreshold : integer Read/Write. When more than threshold lines are present, all get written to the log file (this is for interactive mode only, for non-interactive mode ALL lines get written to the log file)
Running Filters
execute() : boolean Runs the current filter (same as the 'Go' button). This function does not return until the thread completes.

Returns true on success, False on failure (with error message in errorText)

executeClipboard() : boolean Runs the current filter with input from and output to the Clipboard (same as the 'Clipboard' button). This function does not return until the thread completes.

Returns true on success, False on failure (with error message in errorText)

processString( inputText : string ) : string Processes the string inputText and returns the result string, just as though the entire string was in a file.

If an error occurs, errorText will be set to the error message, or blank if there is no error.

compileFilter() : string Compiles the filter into an internal form and saves it so that the compiling doesn't have to be repeated each time text is processed. This function is ONLY used in conjunction with processString(s)WithCompiledFilter - it does not speed up any other process. Any changes made to the filter list after the filter was compiled will not be reflected. Also, the normal Input and Output filters are ignored - a string input and output filter is used instead.

Returns a blank string on success, error message on failure. errorText is also cleared if there is no error, or set if there is an error.

processStringWithCompiledFilter( inputText : string ) : string Processes the string inputText using the pre-compiled filter. If the filter list has not been compiled with compileFilter this function will return an empty string. This function calls startJob and endJob at the beginning and end of processing. Note the singular - String
compiledFilterStartJob()
processStringsWithCompiledFilter( inputText : string ) : string
...
(usually called multiple times)
...
compiledFilterEndJob()
Processes the string inputText using the pre-compiled filter. If the filter list has not been compiled with compileFilter this function will return an empty string. This function DOES NOT call startJob and endJob at the beginning and end of processing - they must be called separately. This function is normally called a number of times. Note the plural - Strings

compiledFilterStartJob() - this function prepares a compiled filter for processing.

compiledFilterEndJob() - this function completes a compiled filter's processing.

isRunning() : boolean Returns true if a processing thread is running
property errorText : string Returns the text of the last error, or blank if there was no last error.
Adding Files
clearAllFiles() Clears all files from the file list
addFile( fileSpec : string, subfolders : integer, action : integer ) Adds a file to the file list.

fileSpec - the filename, folder or wildcard

subfolders - how many subfolders to include (default 255)

0 No subfolders
1..9 1..9 Subfolder(s)
255 All subfolders

action - the action column (default 1)

1 Add the files
2 Subtract the files
3 Ignore the files

 

addFileList( filename : string ) Adds a list of files to the file list.

filename - the list of files is contained in this file.