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

Re: Long strings in CI ///



Okay, it was dumb user error. It takes 5 seconds to run, but
it works. A limitation is that you have to take as the "find"
string, something that's fairly short. I took "With malice
".

The code won't be fully intelligible to you because it uses hack-y right$ and left$ functions from XyBasic (where you see the xybasic.$$$ subroutine).

But here it is, for what it's worth (the bottom part gives the long variable names for the S/Gs):

XPLeNCODE v2.0
b-gin [UNTITLED]
{176}SV01,{177}{176}SV50,{177}{176}SV555,0{177};*;[cr|lf];*;[
cr|lf]{176}SU567,{176}SX561,{176}VANW{177}{177}[BC_]d nw=1[XC
_][BC_]ne xybasic.$$$[XC_]{176}PV563{177}[TF_][DF_]{176}SX562
,1{177}{176}LB;A{177}{176}IF{176}PV562{177}>{176}PV564{177}-1
{177}{176}GL;B{177}{176}EI{177}[CR_]{176}SX562,{176}PV562{177
}+1{177}{176}GL;A{177}{176}LB;B{177}[DF_][RD_]{176}SX562,1{17
7}{176}LB;C{177}{176}IF{176}PV562{177}>{176}PV565{177}{177}{1
76}GL;D{177}{176}EI{177}[CR_]{176}SX562,{176}PV562{177}+1{177
}{176}GL;C{177}{176}LB;D{177}[DF_][BF_][DF_][RD_][DF_][TF_][D
F_]{176}SV566{177}[BC_]ab[XC_][BC_]d nw={176}PV561{177}[XC_][
BC_][NO_]{177}{176}SV02,With malice {177}[cr|lf]{176}SV03,Fou
rscore and seven years ago our fathers brought forth upon thi
s continent a new nation, conceived in liberty, and dedicated
 to the proposition that all men are created equal. Now we ar
e engaged in a great civil war, testing whether that nation,{032}
or any nation so conceived and so dedicated, can long endure.
 We are met on a great battlefield of that war. We have come{032}
to dedicate a portion of that field as a final resting-place{032}
for those who here gave their lives that that nation might li
ve. It is altogether fitting and proper that we should do thi
s. But in a larger sense we cannot dedicate, we cannot consec
rate, we cannot hallow this ground. The brave men, living and
 dead, who struggled here, have consecrated it far above our{032}
poor power to add or detract. The world will little note, nor
 long remember, what we say here. But it can never forget wha
t they did here. It is for us, the living, rather to be dedic
ated here to the unfinished work which they who fought here h
ave thus far so nobly advanced. It is rather for us to be her
e dedicated to the great task remaining before us, that from{032}
these honored dead we take increased devotion to that cause f
or which they gave the last full measure of devotion; that we
 here highly resolve that these dead shall not have died in v
ain; that this nation, under God, shall have a new birth of f
reedom, and that government of the people, by the peopl
e, and for the people, shall not perish from the earth.{177}{
176}SX04,{176}VA$P.{177}{177}{176}SV05,]^]{177}{176}SX06,{176
}IS04{177}+"ci ///"+{176}IS02{177}+{176}IS05{177}{177}{176}SX
07,{176}VA|06{177}{177}{176}SX08,80-{176}PV07{177}{177}{176}S
X08,{176}PV08{177}-1{177};*;[cr|lf]{176}IF{176}PV08{177}<4{17
7}[BC_]use a shorter 'find' string{176}GL_1{177}{176}EI{177};
*;[cr|lf][DX_][BX_]gofile t.x[Q2_];*;[cr|lf]{176}IF{176}ER{17
7}{177}[BX_]ca t.x[Q2_]{176}EI{177};*;[cr|lf][TF_];*;[cr|lf]{
176}LBA{177};*; INITIAL.REPLACEMENT [cr|lf]{176}SX563,{176}IS
03{177}{177}{176}SX564,1{177}{176}SX565,{176}PV08{177}{177}{1
76}GT567{177}{176}SX09,{176}IS566{177}{177}[BX_]ci {181}{176}
PV02{177}{181}{176}PV09{177}{176}PV05{177}{181}[Q2_];*;[cr|lf
]{176}SX10,{176}VA|03{177}{177}{176}SX563,{176}IS03{177}{177}
{176}SX564,@SIZ({176}IS03{177})+1-({176}PV10{177}-{176}PV08{1
77}){177}{176}SX565,{176}PV10{177}-{176}PV08{177}{177}{176}GT
567{177}{176}SX11,{176}IS566{177}{177};*;[cr|lf]{176}LBB{177}
;*; LOOP [cr|lf];*;[cr|lf]{176}IF{176}VA|11{177}<={176}PV08{1
77}{177}[BX_]ci /{176}PV05{177}/{176}PV11{177}/[Q2_];*;[cr|lf
]{176}GLC{177}{176}EI{177};*;[cr|lf]{176}SX563,{176}IS11{177}
{177}{176}SX564,1{177}{176}SX565,{176}PV08{177}{177}{176}GT56
7{177}{176}SX12,{176}IS566{177}{177}[BX_]ci {181}{176}PV05{17
7}{181}{176}PV12{177}{176}PV05{177}{181}[Q2_];*;[cr|lf]{176}S
X13,{176}VA|11{177}{177}{176}SX563,{176}IS11{177}{177}{176}SX
564,@SIZ({176}IS11{177})+1-({176}PV13{177}-{176}PV08{177}){17
7}{176}SX565,{176}PV13{177}-{176}PV08{177}{177}{176}GT567{177
}{176}SX11,{176}IS566{177}{177}{176}GLB{177};*;[cr|lf]{176}LB
C{177};*; OUT.LOOP [cr|lf];*;[cr|lf];*;[cr|lf]{176}LB_{177};*
;[cr|lf]{176}SV50,555-598{177}[JM_]2.clearsgts[Q2_]{176}PV01{
177}{176}EX{177};*;[cr|lf]{176}LB_1{177};*;[cr|lf]{176}SV50,5
55-598{177}[JM_]2.clearsgts[Q2_]{176}PV01{177}{176}EX1{177}[c
r|lf]   Variables & Subs                        Labels[cr|lf]
  01 = NULL$                            lbA =   INITIAL.REPLA
CEMENT    [cr|lf]  50 = U2$                              lbB{032}
=   LOOP      {032}
            [cr|lf] 555 = INKEY.I                          lb
C =   OUT.LOOP               [cr|lf]  02 = FIND$            {032}
                                              [cr|lf]  03 = W
HOLE.REPLACE$                                               {032}
  [cr|lf]  04 = D.PATH$                                     {032}
                   [cr|lf]  05 = SEP$                       {032}
                                    [cr|lf]  06 = OVERHEAD$ {032}
                                                     [cr|lf]{032}
 07 = OVERHEAD.L                                            {032}
         [cr|lf]  08 = CHUNK.SIZE                           {032}
                          [cr|lf]  09 = FIRST.REPLACEMENT.CHU
NK$                                        [cr|lf]  10 = WHOL
E.REPLACE.L                                                 [
cr|lf]  11 = REMAINING.REPLACEMENT$                         {032}
                [cr|lf]  12 = NEXT.CHUNK.TO.ADD$            {032}
                                 [cr|lf]  13 = REMAINING.REPL
ACE.L                                             [cr|lf]Subr
outine 557 handles Input command and 567 handles Mid$/Left$/R
ight$.[cr|lf]
-nd
XPLeNCODE




Reply to note from Harry Binswanger Wed, 01 Dec
2010 09:09:15 -0500

Harry:

> As to my routine, I don't see how it could fail, provided the
> separator (%% in my example) is completely unique.

I still can't visualize it. Let's take a concrete example. Suppose
we have a document consisting entirely of the last paragraph of
Lincoln's Second Inaugural, thus:

-- existing text --
With malice toward none, with charity for all, with firmness in the
right as God gives us to see the right, let us strive on to finish
the work we are in, to bind up the nation's wounds, to care for him
who shall have borne the battle and for his widow and his orphan, to
do all which may achieve and cherish a just and lasting peace among
ourselves and with all nations.
-- end existing --

We want to replace that entire text with the text of the Gettysburg
Address, thus:

-- replacement text --
Fourscore and seven years ago our fathers brought forth upon this
continent a new nation, conceived in liberty, and dedicated to the
proposition that all men are created equal. Now we are engaged in a
great civil war, testing whether that nation, or any nation so
conceived and so dedicated, can long endure. We are met on a great
battlefield of that war. We have come to dedicate a portion of that
field as a final resting-place for those who here gave their lives
that that nation might live. It is altogether fitting and proper
that we should do this. But in a larger sense we cannot dedicate, we
cannot consecrate, we cannot hallow this ground. The brave men,
living and dead, who struggled here, have consecrated it far above
our poor power to add or detract. The world will little note, nor
long remember, what we say here. But it can never forget what they
did here. It is for us, the living, rather to be dedicated here to
the unfinished work which they who fought here have thus far so
nobly advanced. It is rather for us to be here dedicated to the
great task remaining before us, that from these honored dead we take
increased devotion to that cause for which they gave the last full
measure of devotion; that we here highly resolve that these dead
shall not have died in vain; that this nation, under God, shall have
a new birth of freedom, and that government of the people, by the
people, and for the people, shall not perish from the earth.
-- end replacement --

How would your procedure do that?

BTW, I just used BIGCHG (12/1/10 revision) to do this and it worked
fine.

(Obviously it only makes sense to use a routine like BIGCHG where
the subject document contains multiple instances of the search
string. To replace a single instance, cut-and-paste is more
efficient. The above example is for testing purposes.)

--
Carl Distefano
cld@xxxxxxxx


Harry Binswanger
hb@xxxxxxxx