replaceText problem

Peter Haworth pete at lcsql.com
Sun Jan 4 15:25:13 EST 2015


Hi Kay,
To be honest, I've been through so many iterations of this that I don't
remember for sure if the command I cited in my post was exactly what I had
in the script at the time.

I'd be almost certain that I had a "put" in there since I knew it was a
function, but it's very possible that the extraneous "(" was there and the
runtime error was because it was an invalid regex.  I had included ?(im) at
one point (it's back in there now) so I probably didn't quite get rid of
the parens.

Back on the need for a put or a get with a function, it's interesting to
note that you don't have to do that in the message box.  Executing  -
replaceText("abc","c","z") - in the message box puts "abz" into the message
box result area.

Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Sat, Jan 3, 2015 at 8:13 PM, Kay C Lan <lan.kc.macmail at gmail.com> wrote:

> On Sat, Jan 3, 2015 at 10:41 AM, Peter Haworth <pete at lcsql.com> wrote:
>
> >
> > replaceText(pScript,"(^\s*breakpoint$"," ")
> >
> > Hi Peter,
>
> If this is exactly how your script is written then I see two problems:
>
> 1) you need to actually put the result into something so:
>
> put replaceText(pScript,"(?im)^\s+breakpoint$","--BREAKPOINT") into
> tUpdatedScript
>
> (it's one of my pet peeves with the Docs; the examples given are typically
> unworkable as a straight Copy and Paste into a script  - but that's another
> rant]
>
> replaceText - a function, does not work like replace - a command
>
> 2) you have an opening ( prior to your ^. I think you meant to have (?m) or
> even better (?im) so it's case insensitive and works multi-line but in your
> troubleshooting maybe the ( got left behind.
>
> I do what you do but instead of replacing the 'breakpoint' with nothing I
> merely comment it out and make it STANDOUT - as shown in the code above.
> Usually my hard breakpoints have ended up in their location because of some
> long hard troubleshooting so I don't wish to loose them. if I ever need to
> return to a handler for more troubleshooting, if there is the odd --
> BREAKPOINT in there then the first thing I do is uncomment them and step
> through and see what the variables are telling me.
>
> HTH
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list