Buy Download Tour

Did you know? You can generate VBScript or JScript code from a filter prototype by choosing File Menu\Export\Export VBScript or Export JScript. You can even generate a web page to run a filter from a friendly front-end.

For the TextPipe Engine, just substitute 'TextPipeEngine.Application' for 'TextPipe.Application'

Running an existing filter

This example simply loads and runs a predefined filter.

Dim TextPipeApp, Filter
Set
TextPipeApp = CreateObject("TextPipe.Application")
Set Filter = TextPipeApp.newWindow
Filter.openFilter( "C:\Program Files\TextPipe\EText\Centre text.fll" )
Filter.execute()
Set
Filter = Nothing
Set
TextPipeApp = Nothing

Processing a string in memory

This sample loads a predefined filter, then uses it to process and display a string.

Dim TextPipeApp, Filter
Set
TextPipeApp = CreateObject("TextPipe.Application")
Set Filter = TextPipeApp.newWindow
Filter.openFilter( "C:\Program Files\TextPipe\Fun\morse code.fll" )
msgbox "Converted text is: " & Filter.processString( "Hello from Mork" )
Set Filter = Nothing
Set
TextPipeApp = Nothing

Creating a filter on the fly

' addFile action - the action column
const afaAddTheFiles = 1

Dim
TextPipeApp, Filter
Set
TextPipeApp = CreateObject("TextPipe.Application")
Set Filter = TextPipeApp.newWindow
Filter.startFilters
Filter.addSimpleFilter( 42 )    'randomize case
Filter.addLineNumberFilter( 20, 33, false, true, "%5.5d " )   'start number, increment
Filter.endFilters
Filter.addFile "c:\aemail\*.*", 3, afaAddTheFiles   '3 subfolders
Filter.execute()
Set
Filter = Nothing
Set
TextPipeApp = Nothing

A more complex example

Here's an example of TextPipe's powerful COM interface in action, using Windows Script. To use this example, save this text to a file (eg textpipe_example.vbs) and then double click it. You must also have Windows Script Host installed [more documentation]

option explicit

'This sample VBScript demonstrates how to create a TextPipe application object,
'create a new filter window, load a filter into it and then manipulate the
'filter list.
'
'Please see the TextPipe help file for function names and numeric values
'to use for each filter type

' DEFINE ENUMERATED CONSTANTS
' addSelectionFilter Type - the type of filter to add
const slftDeleteColumn = 0
const slftSelectLines = 1
const slftSelectColumns = 2
const slftSelectCsvFields = 4
const slftSelectTabDelimitedFields = 5

' addSelectionFilter Locate Method - how to determine which areas to affect
const sflSelectLineToLine = 0
const sflSelectLinesStartingAtLine = 1
const sflSelectLinesStartingAtLinesFromEnd = 2
const sflSelectLineToLinesFromEnd = 3
const sflSelectLinesFromEndToLinesFromEnd = 4

' addGrepFilter Type - the type of filter to add
const gftSelectLinesMatching = 0
const gftSelectLinesNotMatching = 1
const gftExtract = 2

' addMergeFilter Type - the type of filter to add
const mftMergeIntoFilename = 0
const mftOnlyShowLinesFoundInFilename = 1
const mftRemoveLinesFoundInFilename = 2
const mftLinkFilterFilename = 3

' addSortFilter Type - the type of filter to add
const stftAnsiSortCaseInsensitive = 0
const stftAnsiSortCaseSensitive = 1
const stftAsciiSortCaseInsensitive = 2
const stftAsciiSortCaseSensitive = 3
const stftNumericSort = 4
const stftSortByLengthOfLine = 5

' addReplaceFilter Type - the type of filter to add
const rftReplace = 0
const rftPattern = 1
const rftSoundsLike = 2
const rftEditDistance = 3
const rftPerlPattern = 4
const rftBriefPattern = 5
const rftWordPattern = 6

' addNumberFilter Type - the type of filter to add
const nftConvertTabsToSpaces = 0
const nftConvertSpacesToTabs = 1
const nftWordWrap = 2
const nftPadToWidth = 3
const nftCentreInWidth = 4
const nftRightJustifyInWidth = 5
const nftSelectCsvField = 6
const nftSelectTabDelimitedField = 7
const nftTruncateToWidth = 8
const nftForceToWidth = 9

' addDatabaseFilter mode
const dfmDelimitedOutput = 0
const dfmFixedWidth = 1
const dfmXml = 2
const dfmInsertScript = 3

' addEOLfilter inputLineFeeds - the type of incoming line feeds
const eoliUnix = 0
const eoliMac = 1
const eoliDos = 2
const eoliAuto = 3
const eoliFixed = 4

' addEOLfilter outputLineFeeds - the type of outgoing line feeds
const eoloUnix = 0
const eoloMac = 1
const eoloDos = 2
const eoloNone = 3
const eoloString = 4

' addSimpleFilter type - the type of filter to add.
const sftConvertAsciiToEbcdic = 1
const sftConvertEbcdicToAscii = 2
const sftConvertAnsiToOem = 3
const sftConvertOemToAnsi = 4
const sftConvertToUppercase = 5
const sftConvertToLowercase = 6
const sftConvertToTitleCase = 7
const sftConvertToSentenceCase = 8
const sftConvertToToggleCase = 9
const sftRemoveBlankLines = 10
const sftRemoveBlanksFromEndOfLine = 11
const sftRemoveBlanksFromStartOfLine = 12
const sftRemoveBinaryCharacters = 13
const sftRemoveAnsiCodes = 14
const sftConvertIbmDrawingCharacters = 15
const sftRemoveHtmlAndSgml = 16
const sftRemoveBackspaces = 17
const sftResolveBackspaces = 18
const sftRemoveMultipleWhitespace = 19
const sftUuencode = 20
const sftHexEncode = 21
const sftHexDecode = 22
const sftMimeEncodeBase64 = 23
const sftMimeDecodeBase64 = 24
const sftMimeEncodeQuotedPrintable = 25
const sftMimeDecodeQuotedPrintable = 26
const sftUudecode = 27
const sftExtractEmailAddresses = 28
const sftUnscrambleRot13 = 29
const sftHexDump = 30
const sftXxencode = 32
const sftXxdecode = 33
const sftReverseLineOrder = 34
const sftRemoveEmailHeaders = 35
const sftDecimalDump = 36
const sftHttpEncode = 37
const sftHttpDecode = 38
const sftRandomizeLines = 39
const sftCreateWordList = 40
const sftReverseEachLine = 41
const sftConvertToRandomCase = 42
const sftExtractUrls = 43
const sftAnsiToUnicode = 44
const sftUnicodeToAnsi = 45
const sftDisplayDebugWindow = 46
const sftWordConcordance = 47
const sftDeleteAll = 48

' addStringFilter type - the type of filter to add
const stftAddLeftMargin = 0
const stftAddHeader = 1
const stftAddFooter = 2
const stftAddRightMargin = 3
const stftRemoveLines = 4
const stftOnlyShowLines = 5

' setInputBinaryFiles value
const ibfBinaryFilesAreProcessed = 0
const ibfBinaryFilesAreSkipped = 1
const ibfBinaryFilesAreConfirmedBeforeProcessing = 2

' addFile action - the action column
const afaAddTheFiles = 1
const afaSubtractTheFiles = 2
const afaIgnoreTheFiles = 3

dim TextPipeApp, Filter1, Filter2, Filter3, a, b, c, d, e

Set TextPipeApp = CreateObject("TextPipe.Application")
TextPipeApp.visible = true

Set Filter1 = TextPipeApp.newWindow
Filter1.openFilter( "C:\Program Files\TextPipe\EText\Centre text.fll" )
Filter1.startFilters
Filter1.moveCursorToEnd
Filter1.addSimpleFilter( sftConvertToRandomCase )                     'randomize case
Filter1.endFilters

Filter1.clearAllFiles

'demonstrate the various subfolder settings
Filter1.addFile "c:\aemail\*.*", 3, afaAddTheFiles             '3 subfolders
Filter1.addFile "c:\aemail\*.*", 0, afaAddTheFiles             'No subfolders (None)
Filter1.addFile "c:\aemail\*.*", 9, afaAddTheFiles             '9 subfolders
Filter1.addFile "c:\aemail\*.*", 255, afaAddTheFiles           'All subfolders (All)

'demonstrate the various action settings
Filter1.addFile "c:\aemail\*.*", 1, afaAddTheFiles             'Add
Filter1.addFile "c:\aemail\*.*", 1, afaSubtractTheFiles        'Subtract
Filter1.addFile "c:\aemail\*.*", 1, afaIgnoreTheFiles          'Ignore

'Demonstrate manipulating adhoc text
msgbox "Converted text is: " & Filter1.processString( "Hello from Mork" )

'Release object variables
Set Filter1 = Nothing


'open a second filter window
Set Filter2 = TextPipeApp.newWindow

Filter2.openFilter( "C:\Program Files\TextPipe\Fun\morse code.fll" )
Filter2.clearAllFiles
Filter2.startFilters
a = Filter2.addCommentFilter( "my comment" )
b = Filter2.addLineNumberFilter( 20, 33, false, true, "%5.5d " )          'start number, increment

'Please see the TextPipe help file for function names and numeric values
'to use for each filter type
c = Filter2.addStringFilter( stftAddLeftMargin, "11" )
d = Filter2.addStringFilter( stftAddHeader, "11" )
e = Filter2.addStringFilter( stftAddFooter, "11" )

'now create a subfilter where b and c are contained inside a
Filter2.makeSubfilterOf a, b
Filter2.makeSubfilterOf a, c
Filter2.endFilters

'process the results on the clipboard
Filter2.executeClipboard

'Demonstrate manipulating adhoc text
msgbox "Converted text is: " & Filter2.processString( "Hello from Mork" )

'Release object variables
Set a = Nothing
Set b = Nothing
Set c = Nothing
Set d = Nothing
set e = Nothing
Set Filter2 = Nothing

Set Filter3 = TextPipeApp.newWindow
Filter3.startFilters
a = Filter3.addReplaceFilter( "a", "b", rftReplace, true, false, true, true, 0, false, false, false )
Filter3.endFilters
Filter3.compileFilter

MsgBox Filter3.processStringWithCompiledFilter( "Hello there Andy" )
MsgBox Filter3.processStringWithCompiledFilter( "Andrea says 'HELLO ANDY' back" )

'Release object variables
Set a = Nothing
Set Filter3 = Nothing
TextPipeApp.visible = false
Set TextPipeApp = Nothing

msgbox "End of demonstration"
Buy Download Tour