Home > Archive > Programming with dBASE > October 2005 > Applylocate with a "\"









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Applylocate with a "\"
Fred van der Meulen

2005-10-20, 8:26 pm

Hello,

I'm trying to perform a applylocate with a value that contains a "\". This
does not seem to work. Can someone confirm this? Please try the following
example:

* -- create testtable and fill it
if file("testtable.dbf")
delete table("testtable.dbf")
endif
create table "testtable.dbf" (subj_id character(18))
for i = 1 to 50
cString = str(i,12,0,"0")+"\OB"
insert into "testtable.dbf" (subj_id) values ("&cString")
endfor
* -- trying to find it.
cString = "000000000020\OB"
q = new query()
q.sql = [select * from "testtable.dbf"]
q.active = true
if q.rowset.applylocate( "subj_id = '" + cString + "'" )
msgbox("found it!")
endif
q.active = false
release object q
release q
*************

Thanks in advance.

Regards,
Fred.


Frank J. Polan

2005-10-20, 8:26 pm

Fred

I can confirm it doesn't work - dBASE PLUS 2.6 Win XP Pro
It will work with any character except "\" probably because the "\"
is an escape character and "\0B" has a special meaning (can't
remember what it is)

Frank Polan

On Mon, 17 Oct 2005 21:59:17 +0200, "Fred van der Meulen"
<ns_f. vandermeulen_ns@wana
doo.nl> wrote:

>
>Hello,
>
>I'm trying to perform a applylocate with a value that contains a "\". This
>does not seem to work. Can someone confirm this? Please try the following
>example:
>
>* -- create testtable and fill it
>if file("testtable.dbf")
> delete table("testtable.dbf")
>endif
>create table "testtable.dbf" (subj_id character(18))
>for i = 1 to 50
> cString = str(i,12,0,"0")+"\OB"
> insert into "testtable.dbf" (subj_id) values ("&cString")
>endfor
>* -- trying to find it.
>cString = "000000000020\OB"
>q = new query()
>q.sql = [select * from "testtable.dbf"]
>q.active = true
>if q.rowset.applylocate( "subj_id = '" + cString + "'" )
> msgbox("found it!")
>endif
>q.active = false
>release object q
>release q
>*************
>
>Thanks in advance.
>
>Regards,
>Fred.
>
>



Roland Wingerter

2005-10-20, 8:26 pm

Fred van der Meulen wrote

>
> I'm trying to perform a applylocate with a value that contains a "\". This
> does not seem to work. Can someone confirm this? Please try the following
> example:

------
You need to use a double backslash in your search string to make it work.

Roland


Fred van der Meulen

2005-10-20, 8:26 pm

Frank,

Thank you for trying.

Regards,
Fred.

> I can confirm it doesn't work - dBASE PLUS 2.6 Win XP Pro
> It will work with any character except "\" probably because the "\"
> is an escape character and "\0B" has a special meaning (can't
> remember what it is)
>
> Frank Polan
>
> On Mon, 17 Oct 2005 21:59:17 +0200, "Fred van der Meulen"
> <ns_f. vandermeulen_ns@wana
doo.nl> wrote:
>
>
>


Fred van der Meulen

2005-10-20, 8:26 pm

Roland,

Indeed, this works. Could you explain why I have to use a double backslash?

Regards,
Fred.

> Fred van der Meulen wrote
> ------
> You need to use a double backslash in your search string to make it work.
>
> Roland
>
>


Roland Wingerter

2005-10-20, 8:26 pm

Fred van der Meulen
>
> Indeed, this works. Could you explain why I have to use a double
> backslash?

------
The backslash is used as an escape character. For example, when you use an
apostrophe in a search string you also have to put a backslash before it.

Roland


Fred van der Meulen

2005-10-20, 8:26 pm

Hello Roland,

> The backslash is used as an escape character. For example, when you use an
> apostrophe in a search string you also have to put a backslash before it.


Then it is strange that the following example will find 1 record. Now I am even more puzzled.

* -- create testtable and fill it
if file("testtable.dbf")
delete table("testtable.dbf")
endif
create table "testtable.dbf" (subj_id character(18))
for i = 1 to 50
cString = str(i,12,0,"0")+"\OB"
insert into "testtable.dbf" (subj_id) values ("&cString")
endfor
* -- trying to find it.
cString = "000000000020\OB"
q = new query()
q.sql = [select * from "testtable.dbf" where subj_id = "]+cString+["]
q.active = true
msgbox("found "+q.rowset.count()+" record(s).")
q.active = false
release object q
release q
******************

Regards,
Fred.

Roland Wingerter

2005-10-20, 8:26 pm

Fred van der Meulen wrote

>
>
> Then it is strange that the following example will find 1 record. Now I am
> even more puzzled.

-------
Yeah, I see what you mean. It seems that the double backslash is required in
applyLocate, but not in an SQL Where-clause.

And Findkey does not need a double backslash either.

Roland



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com