String Search & Replace?

Joe Chasan joe at magnatechonline.com
Thu Nov 4 07:51:26 PST 2004


On Thu, Nov 04, 2004 at 10:21:10AM -0500, Tim Fischer wrote:
> Sorry, I wasn't clear enough.  I did test it out and see that it was only
> replacing single characters the way I was using it.  My "(is this true?)"
> statement was to see if anyone knew a work-around for this.
> 
> Sorry for not being clear enough.
> 
> Tim Fischer
> 
> > -----Original Message-----
> > From: joe at magnatechonline.com [mailto:joe at magnatechonline.com]
> > Sent: Thursday, November 04, 2004 10:07 AM
> > To: Tim Fischer
> > Cc: 'filePro mailing list'
> > Subject: Re: String Search & Replace?
> > 
> > On Thu, Nov 04, 2004 at 09:19:15AM -0500, Tim Fischer wrote:
> > > I'm running into an issue where I need to take all the "'s out of a
> > string
> > > and replace them with \".  It needs to be entirely dynamic as I don't
> > know
> > > where in the string the "'s will be.
> > >
> > > I've checked the xlate statement, but it looks like I can only do single
> > > character replacement (is this true?) which wouldn't work as I need to
> > > escape the quote.
> > >
> > > Obviously, I could use the mid() statement in a huge loop, but with the
> > > amount of fields - and the size of fields, I'd end up taking too large
> > of a
> > > performance hit.
> > >
> > > Any ideas?
> > 
> > while i agree that the help for xlate does not specifically state you
> > can us it on multiple occurences of the same character or string, but
> > it does - in the time it took you to type your message, you could just
> > as easily have typed in a simple test
> > @wlf1::1=xlate(1,chr("34"),chr("92")); display; end
> > 
> > plugged in some sample data on screen and see it work.
> > 
> > --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---
> > -Joe Chasan-                      Magnatech Business Systems, Inc.
> > joe at magnatechonline.com           Hicksville, NY - USA
> > http://www.MagnatechOnline.com    Tel.(516) 931-4444/Fax.(516) 931-1264

i reread your message and now understand - you want to replace
a " with a \" - e.g. from 1 to 2 characters - xlate will not do 
that and i don't know of a simple function that will - after all,
it requires some judgement as to what to do if lets say because of 
adding on characters the string no longer fits into the allotted
length.

you could make a complicated loop with mid, as you suggest, and
also making sure that it is only run once, as you can guess what
will happen with each pass on the same data.

i don't think you can do it with an edit as filepro reserves the
double-quotes for its own use in edits (and hacking this from outside
fp's define edits, the running will result in seg-v or dos/win equiv)

--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---
-Joe Chasan-                      Magnatech Business Systems, Inc.
joe at magnatechonline.com           Hicksville, NY - USA
http://www.MagnatechOnline.com    Tel.(516) 931-4444/Fax.(516) 931-1264


More information about the Filepro-list mailing list