Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Packaging TPIPE

May
12,934
171
I like TPIPE because it's so powerful (and fast if you're doing enough). But I'm not crazy about getting out the manual every time I want to compose a TPIPE command line. I have often wondered how I might "package" TPIPE. Here's one way. It emulates GREP's with 3 common and basic options. BTM file at the end.

Code:
Syntax:  [|] TPGREP.BTM [/u] [/v] [/i] pattern [file]

Examples: My TCMD.INI is unicode but TYPE's output typically isn't, so ...
Code:
v:\> tpgrep /u /i "V:\\" g:\tc15\tcmd.ini
StartDirectory=v:\
 
v:\> type g:\tc15\tcmd.ini | tpgrep "v:\\"
StartDirectory=v:\

Here's the (no-frills) BTM file.
Code:
setlocal
set bUnicode=0
set bCase=1
set bReverse=0
 
do while "%@instr[0,1,%1]" == "/"
iff "%1" == "/u" then
    set bUnicode=1
    shift
elseiff "%1" == "/i" then
    set bCase=0
    shift
elseiff "%1" == "/v" then
    set bReverse=1
    shift
endiff
enddo
tpipe %@if[%_pipe == 1,,/input=%2] %@if[%bUnicode == 1,/simple=45,] /grep=%@if[%bReverse == 0,3,4],0,0,%@if[%bCase=1,1,0],0,0,0,0,%1
 
Back
Top