Subject Re: Character ' and applylocate some opinion would be welcome
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Wed, 6 Apr 2022 07:48:32 -0700
Newsgroups dbase.getting-started

On 4/6/2022 5:18 AM, Dirk wrote:
> Hello
>
> i am playing around with Mastersource
>   as far all ok
>
> now i was a bit surprised about searching with applylocate for a name
> starting with a ' like 't veer
>
> got a an error
>
> when query without params when searchin for '
>
> when query with an param : ' is accepted, see //
>
>   function Veld_Zoek_onKey(nChar, nPosition,bShift,bControl)
>      local cVeld
>       cVeld = "name = ' "+rtrim(+this.value)+" ' "
>          this.parent.vraagbak_klant.rowset.locateOptions = 3
>             this.parent.vraagbak_klant.rowset.beginlocate()
>           this.parent.vraagbak_klant.rowset.ApplyLocate(cVeld)
>
>    //  this.parent.vraagbak_klant.params["letter"] =
> lower(ltrim(rtrim(this.value))+ "%")
>    //   this.parent.vraagbak_klant.requery()
>    //    this.parent.vraagbak_klant.rowset.first()
>    //     this.parent.Veld_zoek.setFocus()
>
> now when i use this
>
> function Veld_Zoek_onKey(nChar, nPosition,bShift,bControl)
>      local cVeld
>       //cVeld = "name = ' "+rtrim(+this.value)+" ' "
>         this.parent.vraagbak_klant.params["letter"] =
> lower(ltrim(rtrim(this.value))+ "%")
>        this.parent.vraagbak_klant.requery()
>        cVeld = "name = ' "+rtrim(+this.value)+" ' "
>       //   this.parent.vraagbak_klant.rowset.locateOptions = 3
>         //    this.parent.vraagbak_klant.rowset.beginlocate()
>           this.parent.vraagbak_klant.rowset.ApplyLocate(cVeld)
>            this.parent.vraagbak_klant.rowset.first()
>
> working aswell
>
> so i think the last function is doing the same
> once by requering and once by applylocate
> the point is how to use applylocate without param in the query
> and finding words starting with ' ( all others characters are accepted)
>
> thanks for some additional informatien,

The applyLocate() (and filter) options are limited to what SQL they
understand (the limits are really based on the BDE itself, not on
anything in dBASE).

You need to look at the locateOptions (and if you use filter,
filterOptions), although it seems that using 3 (Match partial length and
ignore case) as you are above, should do the trick. One problem might be
if you are looking for words starting with an apostrophe ('), is that
apostrophes or single-quotes are delimiters in dBASE and SQL, as are
double-quotes. It might help you to build your commands using the square
brackets. The other thing is if you do " ' " dBASE is going to be
looking for the spaces as well ...

Just a few things to think about. Maybe someone with more experience
with params can also step in and throw some advice in ...

Ken


--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm