1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Packaging TPIPE

Discussion in 'T&T - Scripting' started by vefatica, Jun 24, 2013.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    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
     
    
     
    fromano likes this.
  2. fromano

    Joined:
    May 20, 2008
    Messages:
    110
    Likes Received:
    0
    Nice :)
     

Share This Page