The Un-Official Proxomitron Forum
How to use $LST(Count) in Replace ? - Printable Version

+- The Un-Official Proxomitron Forum (https://www.prxbx.com/forums)
+-- Forum: Proxomitron Filters (/forumdisplay.php?fid=38)
+--- Forum: Filter Help/Request (/forumdisplay.php?fid=31)
+--- Thread: How to use $LST(Count) in Replace ? (/showthread.php?tid=2069)



How to use $LST(Count) in Replace ? - prxymouse - Dec. 22, 2012 10:55 AM

Hi,

longtime user who got by modifying posted filters and creating simple website specific filters but now I have a question on how to use the counter filter.

I want to wrap PRE tags in a TABLE tag which would allow me to use javascript to copy specific "tables" to the clipboard. This simple filter works (improvements welcome of course)
Code:
Match = "<pre\1/pre>"
Replace = "<table border="0"><tr><td><pre\1/pre></td></tr></table>"
But there can be more as one PRE on a page I need a unique ID added to the table so I thought of adding a counter like table id=pre1, table id=pre2 etc but I have no clue on how to use the $LST(Count). If I simply do this
Code:
Match = "<pre\1/pre>"
Replace = "<table border="0" id=pre($TST(($GET(n)+)=$LST(Count)|*)$SET(n=$GET(i)))><tr><td><pre\1/pre></td></tr></table>"

I get ProxomiTron Application Error - Read Over=randomhugenumber msgboxes (which I will admit never had seen before)

Any guidance or tips would be appreciated.


RE: How to use $LST(Count) in Replace ? - JJoe - Dec. 22, 2012 10:54 PM

Code:
[Patterns]
Name = "Example"
Active = FALSE
Limit = 4096
Match = "<pre\1/pre>"
        "$TST(($GET(PreIdC)+)=$LST(Count)|*)$SET(PreIdC=$GET(i))"
Replace = "<table border="0" id="pre$GET(PreIdC)"><tr><td><pre\1/pre></td></tr></table>"

HTH


RE: How to use $LST(Count) in Replace ? - prxymouse - Dec. 23, 2012 12:55 PM

Thank you, I suspect it is pretty close but haven't gotten it to work yet.

But before I experiment further with $LST etc I want to understand how to use $SET and $GET
but when I try the GET example http://www.proxomitron.info/45/help/Matching%20Commands.html#GET

It doesn't seem to work and says "No Match" in the testing window, if I remove the "$SET(LinkURL=>>\1<<)" part from the Match it does find a match, but it simply prints "The linked URL was: $GET(LinkURL)" I really wonder what I am doing wrong for some reason it refuses to SET any variable because if I "(\1)$SET(test=SetGetText)" to get the test variable it says No Match. Weird.

I can get the SET example (above the GET with the Name=one two three) to work.


RE: How to use $LST(Count) in Replace ? - JJoe - Dec. 23, 2012 05:26 PM

prxymouse Wrote:Weird.

Yeah. Please, post the filter and code tested against.

help Wrote:The $GET command can be used it in any replacement text to insert the current value of a global variable created by $SET (see above). This may even be within another $SET command. For example...

Match: <a * href=$AVQ(\1)$SET(LinkURL=>>\1<<) *>
Replace: "The linked URL was: $GET(LinkURL)"

So a filter like

Code:
[Patterns]
Name = "Test"
Active = FALSE
Limit = 256
Match = "<a * href=$AVQ(\1)$SET(LinkURL=>>\1<<) *>"
Replace = "The linked URL was: $GET(LinkURL)"

tested against

Code:
<a href="http://www.proxomitron.info/45/help/Matching%20Commands.html#GET">

test window Wrote:The linked URL was: >>"http://www.proxomitron.info/45/help/Matching%20Commands.html#GET"<<

After I remove "$SET(LinkURL=>>\1<<)",

test window Wrote:The linked URL was:

Case is important, must be $SET and $GET.


RE: How to use $LST(Count) in Replace ? - prxymouse - Dec. 23, 2012 10:03 PM

To quote Homer Simpson: Doh!

When I started looking into this $LST(Count) I also tried various patches and versions, somehow it seems I forgot to switch back to the "good" version and I was running 4.3.0 which of course doesn't support SET/GET at all. Going back to 4.5 did the trick and unique IDs are now created and I can finish my project.

Thank you very much and Happy Holidays!