Subject Re: Character ' and applylocate some opinion would be welcome
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 7 Apr 2022 10:48:54 +0200
Newsgroups dbase.getting-started

On 2022/04/06 17:55, Mervyn Bick wrote:

> oRef.applyLocate("name = '\'t veer'")
>
> A little example is attached.

Oops.  My mind was really in neutral when I created that example and,
once again, it proves the old definition of test data i.e the only data
with which the program will actually work.

As it stands the escape_apostrophe() function will only work where there
is only one apostrophe in the string.  If there is more than one
apostrophe an additional escape character will be added to the first
apostrophe in the string for each apostrophe.  Needless to say, this
will cause a problem. :-(

Please use this revised version of the function.

    function escape_apostrophe(cString)
       // Add  \ as an escape charater before '
       if [']$cString
        for n = len(cString) to 1 step -1
             if substr(cString,n,1) = [']
//               cString = stuff(cString,at(['],cString),0,[\])
                cString = stuff(cString,n,0,[\])
             endif
          next
       endif
       return cString

Mervyn.