- May
- 13,272
- 187
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.
Examples: My TCMD.INI is unicode but TYPE's output typically isn't, so ...
Here's the (no-frills) BTM file.
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