[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: XPL questions (error with multiple contiguous Wild-Ws)



** Reply to message from Harry Binswanger  on Tue, 05 Sep 2006
00:20:16 -0400

Harry:

> Find: {CR}http://{W}{W}{W}{W}{CR}
> Repl: {CR}≪LBhttp://{W}{W}{W}{W}{CR}

This has never worked. I'm pretty sure that we have
discussed this several times. You can use contiguous
strings of just about any other wildcard, if it
represents a single character, e.g.:
 Find: {CR}http://{X}{X}{X}{X}{CR}
 Repl: {CR}≪LBhttp://{X}{X}{X}{X}{CR}
but you need to have real characters on either side of a
wild-W to demarcate the wild string in a CHange command.
Undemarcated wild-Ws on the find side (or in a SEarch) will
work, but not on the replace side.

It's a true predicament because there is no generic,
alternative solution -- only SEarch-and-loop approaches,
each crafted for a specific situation with specific
characters. Now, I wrote a generic workaround several years
ago -- I never quite finished the program, but it definitely
solved the problem. Took another look this morning, made a
couple of refinements, and here it is: frame LONGW*. It is
a replacement for CH[A] or CV[A] that accepts a Wild-W of
*any* length. Syntax:

CMline:
 LONGW[A][V][/#] {separator}find${separator}replace${separator}
XPL:
 JM 2.LONGW[A][V][/#]Q2

Note that this differs not at all from standard CHange syntax.
BUT, there are several rules and quirks, to wit:
1) You must use three separator chars. The space separator
  is NOT supported.
2) LONGW* operates from current cursor position to EOF
  only. It won't work (yet) on a DeFined block.
3) Optional arguments: "A" means CHangeA[bsolute]; "V"
  means CHangeVerify. Can use either or both optional
  args. See 4) below for the "#" arg...
4) When your argument contains Wild-W, you just use *ONE*
  Wild-W (not, like your example above, four in a row).
*** That single {W} wildcard stands for "any length" ***
       *** (not just 80 chars)! ***
  This feature is the main departure from native CHange.
  But consider: this freedom could be exploited
  quite unreasonably. For example, you might argue
  something like
 LONGWA |hello{W}there|howdy{W}pardner|
  and the program might change "hello" to "howdy" on page
  1 and "there" to "pardner" on page 15, because there's no
  limitation on the length of Wild-W!! Therefore, there IS
  a default limit, of 400 chars, on the length of the found
  string -- you can optionally change this value on-the-
  fly with a "LONGW[A][V]/#" argument (note the preceding
  slash!), where "#" is any number, like 50 or 1000 or
  whatever. N.B.: the value does NOT represent 400 chars
  of Wild-W -- it means 400 chars of the *whole found
  string*, including all text represented by Wild-Ws (there
  can, of course, be more than one Wild-W if they are NOT
  contiguous).
5) You can use any other wildcards too, excepting the
  numeric wildcards like {4N} or {3X}, which aren't
  supported (yet).
6) The last, very important rule is that there MUST be
  *balanced wildcards* -- identical wildcards appearing in
  the same order -- on both sides of the /find/replace/
  string. It WILL bomb if wildcards are not balanced, and
  (at present) there is no internal check for balance --
  so SAve your bloody file before you use this, and RECAll
  the file (RECA) if you screw something up.
  Balance implies, for example, that you could not
  introduce guillemets on the CMline on the replace side,
  unless they were present also on the find side (but you
  could introduce them with XPL, using real guillemets
  instead of the red pseudo-wildcards -- the reason being
  of course that Xy4 doesn't permit real guillemets on the
  command line, but they are accepted with BX ...Q2 ).

Anyway, I have not tested this bugger to death, but it should
handle your situation with aplomb. You'd shape the
command thus in XPL:
 ≪SV50,|{CR}http://{W}{CR}|{CR}≪LBhttp://{W}{CR}|≫JM 2.longwQ2
or (real code):

XPLeNCODE v2.0
b-gin [UNTITLED]
{<}SV50,|[wC]http://[wW][wC]|[wC]{<}http://[wW]{}[wC]|{>}[JM
_]2.longw[Q2_]{<}EX{>}
-nd
XPLeNCODE

Here's the frame (you need to be using a v119 DECODE frame,
so I attach the code in ZIPped form also, for anyone not
using v119). Plug it in to U2, and let me know...

XPLeNCODE v2.0
b-gin [UNTITLED]
{{;5longw*}} CHange with WildW of any length RJH 9/6/06[cr|l
f]{002};*; Wildcards MUST be balanced! Use just ONE [wW]![cr|
lf]{<}IF{<}VA|50{>}>0{>}{<}SV01,[wW][w<][w>][w13][w10][wC][w-
][255+192+174][wA][wL][wN][wO][wS][wX][w0][w1][w2][w3][w4][w5
][w6][w7][w8][w9]{>};*;[cr|lf];*;{<}SV50,[w5]{>}{<}SX02,(({<}
IS50{>}{238}{<}IS01{>})-42)/3{>}{<}PR@02{>}{<}EX{>};*; <==TES
T[cr|lf]{<}SV02,{027}X{>}{<}XS50,02,,03,04{>};*; {<}SV03{>}=s
eparator, e.g. "|"[cr|lf]{<}XS04,03,05,,06{>}{<}SX07,{<}IS05{
{062}}{>};*; {<}SV05{>}=find side[cr|lf]{<}XS06,03,03,,04{>}{<}SX
08,{<}IS03{>}{>};*; {<}SV03{>}=replace side[cr|lf]{<}SV04,{>}
{<}SX09,@UPR({<}VA$FR{>}){>}{<}IF{<}IS09{>}{240}"A"{>}{<}SV04
,a{>}{<}EI{>};*; {<}SV04{>}="A"bsolute[cr|lf]{<}SV10,{>}{<}IF
{<}IS09{>}{240}"V"{>}{<}SV10,v{>}{<}EI{>};*; {<}SV10{>}="V"er
ify[cr|lf]{<}SX09,400{>}{<}IF{<}VA$FR{>}{240}"/"{>}{<}SX09,{<
}VA$FR{>}{>}{<}SX09,{<}VA@09/2{>}{>}{<}EI{>}{<}SX09,{<}IS09{>
}{>}{<}IF{<}VA{021}09{>}<1{>}{<}SX01,"Bad command: "+{<}IS09{
{062}}{>}{<}LBA{>}[DO_][FF_]{<}PR@01{>}{<}EX{>}{<}EI{>};*; Max si
ze of Find$, default=400[cr|lf]{<}SX11,{<}CP{>}{>}[BX_]es 1[Q
2_][YD_][DX_]{<}SX06,0{>}{<}SX12,0{>}{<}LBB{>}{<}SV13,{>}{<}L
BC{>}{<}XS05,02,,14,15{>}{<}SX05,{<}IS15{>}{>}{<}IF{<}IS14{>}
{238}{<}IS01{>}<>0{>}{<}SX13,{<}IS13{>}+{<}IS14{>}{>}{<}IF{<}
VA|05{>}>0{>}{<}GLC{>}{<}EI{>}{<}EI{>}[BX_]se{<}PV04{>} [999]
{<}PV13{>}[999][Q2_]{<}IF@NOT({<}ER{>}){>}{<}IF{<}PV06{>}>0{>
}{<}SX16,{<}CP{>}-{<}PV50{>}{>}{<}IF{<}PV16{>}>{<}PV09{>}{>}{
<}LBD{>}{<}SX06,0{>}
{<}SX03,{<}IS08{>}{>}{<}SX05,{<}IS07{>}{>}{<}GLB{>}{<}EI{>}{<
}EI{>}[BX_]seb{<}PV04{>} [999]{<}PV13{>}[999][Q2_]{<}IF{<}PV0
6{>}<1{>}{<}SX06,1{>}{<}SX50,{<}CP{>}{>}{<}IF{<}VA|10{>}>0{>}
[DO_][FF_]{<}SV10,Any key changes (Esc aborts){>}{<}PR@10{>}{
<}SX10,{<}RK{>}{>}{<}SX10,{<}VA$KC{>}{>}{<}IF{<}PV10{>}<2{>}{
<}LBE{>}{<}SX01,{<}IS12{>}+" changes"{>}{<}GLA{>}{<}EI{>}[DX_
]{<}EI{>}{<}EI{>}[BX_]se{<}PV04{>} [999]{<}PV13{>}[999][Q2_]{
<}IF{<}VA|05{>}>0{>}{<}GLB{>}{<}EI{>}[JM_]2.ReJuMP[Q2_];*; Va
lid find$?[cr|lf]{<}SX05,{<}IS07{>}{>}{<}SX06,0{>}{<}SX17,0{>
}{<}LBF{>}{<}SV13,{>}{<}LBG{>}{<}XS05,02,,14,15{>}{<}SX05,{<}
IS15{>}{>}{<}IF{<}IS14{>}{238}{<}IS01{>}<0{>}{<}SX13,{<}IS13{
{062}}+{<}IS14{>}{>}{<}IF{<}VA|05{>}>0{>}{<}GLG{>}{<}EI{>}{<}EI{>
}{<}IF{<}IS14{>}{238}{<}IS01{>}>2{>}{<}IF{<}IS14{>}{238}{<}IS
01{>}>41{>}{<}SV01,Numeric wildcards not supported{>}{<}GLA{>
}{<}EI{>}{<}SX13,{<}IS13{>}+{<}IS14{>}{>}{<}EI{>}{<}IF{<}VA|1
3{>}>0{>}{<}IF{<}PV06{>}>0{>}{<}SX06,0{>}[BX_]se{<}PV04{>} [9
99]{<}PV13{>}[999][Q2_][BX_]seb{<}PV04{>} [999]{<}PV13{>}[999
][Q2_]{<}EI{>}[DF_][BX_]se{<}PV04{>} [999]{<}PV13{>}[999][Q2_
]{<}IF{<}IS14{>}{238}{<}IS01{>}>2{>}[CL_]{<}EI{>}[DF_][DN_]{<
}SV13,{>}{<}LBH{>}{<}XS03,02,,18,15{>}{<}SX03,{<}IS15{>}{>}{<
}IF{<}IS18{>}{238}{<}IS01{>}<0{>}{<}SX13,{<}IS13{>}+{<}IS18{>
}{>}{<}IF{<}VA|03{>}>0{>}{<}GLH{>}{<}EI{>}{<}EI{>}{<}GT13{>}{
<}IF{<}IS14{>}{238}{<}IS01{>}>2{>}[CR_]{<}EI{>}{<}EI{>}{<}IF{
<}VA|05{>}>0{>}{<}IF{<}IS14{>}{238}{<}IS01{>}==0{>}{<}SX06,1{
{062}}{<}EI{>}{<}GLF{>}{<}EI{>}{<}SX12,{<}PV12{>}+1{>}{<}GLD{>}{<
}EI{>}{<}SX50,{<}PV11{>}{>}[JM_]2.ReJuMP[Q2_]{<}G
LE{>}{<}EI{>}{<}SV01,No command{>}{<}GLA{>}{002}[cr|lf][cr|lf
]
-nd
XPLeNCODE

-----------------------------
Robert Holmgren
holmgren@xxxxxxxx
-----------------------------

Attachment: LONGW.ZIP
Description: Binary data