Page 1 of 1

Global Variables?

Posted: Sat Feb 10, 2007 5:36 am
by JSMediRegs
I'm having major time trouble trying to figure out how to get a global variable declared. I have a bit of code which I've successfully translated into a local variable (confined to one filter) which I then need to use somewhere else... How?

here's my code for an easy pattern search and replace

search:

Code: Select all

<P CLASS="art-head2">
[ capture( 1+ digits or letters or whitespace or '>' or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|<> )]</P>
replace:

Code: Select all

</doc>
<doc>
<link rel="stylesheet" type="text/css" href="/states.css">
:::uid @inputFilename
:::index @inputFilename
:::date @date
<br><p class ="heading3">$1</p>
From there, I'd like to stop $1 into a global variable... how do I go about doing that?

Thanks!
~Jon
jschwartz@mediregs.com

Posted: Mon Feb 12, 2007 10:03 am
by DataMystic Support
Hi Jon,

Code: Select all

<P CLASS="art-head2"> 
[ capture( 1+ digits or letters or whitespace or '>' or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|<> ) as 'globalvarname' ]</P>
Remember though - you may need to place this pattern inside a restriction - otherwise TP may only give you the value of the LAST occurrence of this variable. Remember - TextPipe acts like each filter processes the ENTIRE file before passing it on - unless you restrict to a small area of text.

Posted: Wed Feb 14, 2007 8:07 am
by JSMediRegs
Ok so now I have it in a restrict to pattern filter which says this

Code: Select all

<P CLASS="art-head2">
[ capture ( 1+ digits or letters or whitespace or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|> ) as 'title1' ]</P>
with the action set to send matching text to sub filter.

In the subfilters, I am using EasyPattern search and replaces on what I believe to be the text found in that restrict filter, right? I am also trying to use the global variable @title1

The only thing I can get it to output when I use the @title1 variable in a subfilter is "1" I know that "1" is not the right answer. What am I doing wrong?

Posted: Wed Feb 14, 2007 8:38 am
by DataMystic Support
Numbers cannot be used as global variable names. What you're seeing for @title1 is
<blank>1

You can't use a global var in the search field, only the replace field.

If you email your filter to us we can help further.