Variables: using @MacroName in the Find field...

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
alnico
Posts: 74
Joined: Fri Oct 12, 2007 11:57 pm

Variables: using @MacroName in the Find field...

Post by alnico »

I know myself and others over the years have requested the Find/Replace filter be able to to accept a @MacroName in the Find field.
I understand the problem with inserting @MacroName into a Find field, i.e. dealing with literals, escaping and speed, etc.

But what if this approach were possible...

Using filter Find/Replace...below the Find field add an optional checkbox: 'Process variables, i.e. @@MacroName'
This would then tell TextPipe to explicitly process the Find field in a different way than normal.

So if we test this...

Find: @@FName\.@@LName@microsoft\.com
NO='Process variables, i.e. @@MacroName'
TextPipe would search for all literals in this case and likely not find any matches (works exactly like current Textpipe).

Now with...

YES='Process variables, i.e. @@MacroName'
TextPipe would internally create a tab deliminated macro replace list from currently declared macros such as:
@@FName\tSimon
@@LName\tCarter
etc.

Once this internal pre-processing (inserting macros into the Find pattern) is done, then continue with the Find as normal.
Find pattern would then be: Simon\.Carter@microsoft\.com (an unlikely match ;-)

If done like this I don't think we have to worry about escaping literals, unless I am missing something.
Will this be slower than 'normal' mode?, yes; but only when explicitly called.

What do you think...is this approach possible?

Thanks,
Brent
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Variables: using @MacroName in the Find field...

Post by DataMystic Support »

Hi Brent,

At the start of a processing job, when the search strings are being compiled into regex form, macros usually have not been defined. The exception to this would be environment variables which would exist unchanged for the lifetime of the processing job.

There is a lot of potential confusion with a filter like this.

1. Search for xxx.xx
1.1. Capture to @PRICE
2. Find @PRICE, replace with 'Undiscounted price is @PRICE'

A user who does not understand TP would not realize that TP runs filter 1 (and subfilter 1.1) to completion, THEN filter 2, which means that filter 2 only works for the final value of @PRICE.

Can you give me an example of how you would like to use this?
alnico
Posts: 74
Joined: Fri Oct 12, 2007 11:57 pm

Re: Variables: using @MacroName in the Find field...

Post by alnico »

I guess what I am after (considering I have done multiple posts all related to this) is:

I want to create find/patterns dynamically and turn around and use them in the same TextPipe file. This is described in my previous post: Alternative to processing multiple files in succession.
viewtopic.php?f=20&t=1306

Ya, I get that 'variables' in Find is difficult...I am going to present yet another possible solution that might kill two birds with one stone ;-)
I will post it in the link above as it relates there more than here, I tagged it with [Macro].

Brent
Post Reply