Welcome!

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

SignUp Now!

Declined TPIPE aliases?

May
13,201
180
Many TPIPE options are long, with many parameters, and are hard to remember. I am not recommending environment variables to do the job, but some way to create and use a "library" of TPIPE aliases would keep me from having to go to the help. Here's an example.
Code:
v:\> echo 222 | tpipe /replace=4,1,0,0,0,0,0,0,0,"\x32","\x33"
333
I had to go to the help to remember the "4,1,0,0,0,0,0,0,0,". Here's an alternative (again, I'm not recommending envvars).
Code:
v:\> set rep=/replace=4,1,0,0,0,0,0,0,0,

v:\> echo 222 | tpipe %[rep]"\x32","\x33"
333

Ideal (???) might be some way to define "rep" so that I could later say
Code:
echo 222 | tpipe /rep="\x32","\x33"
 
Vince, this has room for improvement, but maybe this is something to consider;
Code:
@setlocal
@echo off
tpipe /grep=^
%@iniread[.\%0,config,Type],^
%@iniread[.\%0,config,IncludeLineNumbers],^
%@iniread[.\%0,config,IncludeFileName],^
%@iniread[.\%0,config,MatchCase],^
%@iniread[.\%0,config,CountMatches],^
%@iniread[.\%0,config,PatternType],^
%@iniread[.\%0,config,UTF8],^
%@iniread[.\%0,config,IgnoreEmpty],^
%@iniread[.\%0,config,Pattern]
endlocal
quit

[config]
; Type:
;0 Restrict lines matching (for subfilters)
;1 Restrict lines NOT matching (for subfilters)
;2 Extract matches
;3 Extract matching lines (grep)
;4 Extract non-matching lines (inverse grep)
;5 Remove matching lines
;6 Remove non-matching lines
Type = 3

; IncludeLineNumbers - 1 to include the line number where the pattern was found
IncludeLineNumbers = 0

; IncludeFilename - 1 to include the filename where the pattern was found
IncludeFileName = 0

; MatchCase - 1 to do a case-sensitive comparison when matching the pattern
MatchCase = 0

; CountMatches - 1 to output a count of the number of matches
CountMatches = 0

; PatternType
; 0 Perl pattern
; 1 Egrep pattern
; 2 Brief pattern
; 3 MS Word pattern
PatternType = 0

; UTF8 - 1 to allow matching Unicode UTF8 characters
UTF8 = 0

; IgnoreEmpty - 1 to ignore empty matches
IgnoreEmpty = 0

; Pattern - the (regular expression) pattern to match
Pattern = the

Note well that the .INI file is the .BTM itself.

Example usage;
Code:
c:\users\jlc\utils>type test.txt | tgrep.btm
The
the

Example test.txt;
Code:
The
quick
brown
fox
jumped
over
the
lazy
dog

Joe
 
Excellent stuff, Joe.

However, this idiom does not need any changes in TC.

A single (set of) sourcefile(s) can generate a whole bunch of alias definitions that can be read-in by the user when needed. The only thing missing in cases like this is forum functionality like GitHub or GitLab to create, develop and share sources in a controlled way.
 
Last edited:
I'm still in favor of this sort of enhancement. I don't think environment variables are the way to go ... rather some TPIPE-specific mechanism. Here's a recent (crude) attempt.

Code:
v:\> set tpgrep=/grep=3,0,0,0,0,0,0,0

v:\> tpipe /input=tag.html %tpgrep,inside
inside

v:\> set tpsed=/replace=4,0,0,0,0,0,0,0,0

v:\> echo foo | tpipe %tpsed,o,e
fee
 
Back
Top
[FOX] Ultimate Translator
Translate