dBASE Programming - Found the problem with applylocate

This is Interesting: Free IT Magazines  
Home > Archive > dBASE Programming > October 2006 > Found the problem with applylocate





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 Found the problem with applylocate
evilaro

2006-10-02, 1:21 pm

To all

using this from ken or what I was using the result is the same.
IF FORM.IMAGENES2.ROWSET.applyLocate( [Ctext = ']+MBUSCAR+['])


The reason why it does not find the record with applylocate
is because it contain a \


So if the searched record is [C:\MYTHINGS ]

It will never be located.

if I take the \ out [C:MYTHINGS ]

then no problem.

But ofcourse this is not acceptable!!!!!!!!!!!!

Do you I feel this is a bug?
Can you reproduce the problem?.
Any way around?.

Orrrrrrrrrrr... I am doing something wrong

Thanks

Emilio



Ken Mayer [dBVIPS]

2006-10-02, 1:21 pm

evilaro wrote:
> To all
>
> using this from ken or what I was using the result is the same.
> IF FORM.IMAGENES2.ROWSET.applyLocate( [Ctext = ']+MBUSCAR+['])
>
>
> The reason why it does not find the record with applylocate
> is because it contain a \
>
>
> So if the searched record is [C:\MYTHINGS ]
>
> It will never be located.
>
> if I take the \ out [C:MYTHINGS ]
>
> then no problem.
>
> But ofcourse this is not acceptable!!!!!!!!!!!!
>
> Do you I feel this is a bug?
> Can you reproduce the problem?.
> Any way around?.
>
> Orrrrrrrrrrr... I am doing something wrong


Hmm. Backslashes can be a problem. I wouldn't have thought of it in this
case. dBASE is using local SQL to do applyLocate and all that, and I
have a feeling \n (where n is a character or a number) has special
meanings ... escape codes and all that.

Off the top of my head, I cannot think of a proper solution. Hopefully
someone can.

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/dbase/dBASEBook.htm
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
evilaro

2006-10-02, 1:21 pm

KEN:


> Hmm. Backslashes can be a problem. I wouldn't have thought of it in this
> case. dBASE is using local SQL to do applyLocate and all that, and I
> have a feeling \n (where n is a character or a number) has special
> meanings ... escape codes and all that.
>
> Off the top of my head, I cannot think of a proper solution. Hopefully
> someone can.


I really hope so... a "\" is a very used character.

I have tested using the standard LOCATE
and there is NO problem.

Emilio





David Kerber

2006-10-02, 1:21 pm

In article <PAkm3Ik5GHA.1764@news-server>, dbase@_nospam_goldenstag.net
says...
> evilaro wrote:
>
> Hmm. Backslashes can be a problem. I wouldn't have thought of it in this
> case. dBASE is using local SQL to do applyLocate and all that, and I
> have a feeling \n (where n is a character or a number) has special
> meanings ... escape codes and all that.
>
> Off the top of my head, I cannot think of a proper solution. Hopefully
> someone can.


Two different things to try:

1. Replace the "\" with a "/". If you use all "/"'s, windows will
accept it, and then it won't be confused by thinking you might be using
"\" to excape special characters.

2. Double-up the "\\"'s, so you see "c:\\mythings".


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Vasile Buza

2006-10-02, 7:38 pm


"evilaro" <buzon[NO]@evilfoto.es> wrote in message
news:9q7Nw2j5GHA.1156@news-server...

Emilio,

You can try:

private MBUSCAR

MBUSCAR=FORM.ENTRYFIELD1.VALUE.RIGHTTRIM()
FORM.IMAGENES2.ROWSET.CanGetRow = {|| this.fields["Ctext"].value =
'&MBUSCAR.' }
IF FORM.IMAGENES2.ROWSET.first()
MSGBOX('Found')
ELSE
MSGBOX('Not Found')
ENDIF

Vasile Buza

> To all
>
> using this from ken or what I was using the result is the same.
> IF FORM.IMAGENES2.ROWSET.applyLocate( [Ctext = ']+MBUSCAR+['])
>
>
> The reason why it does not find the record with applylocate
> is because it contain a \
>
>
> So if the searched record is [C:\MYTHINGS ]
>
> It will never be located.
>
> if I take the \ out [C:MYTHINGS ]
>
> then no problem.
>
> But ofcourse this is not acceptable!!!!!!!!!!!!
>
> Do you I feel this is a bug?
> Can you reproduce the problem?.
> Any way around?.
>
> Orrrrrrrrrrr... I am doing something wrong
>
> Thanks
>
> Emilio
>
>
>



evilaro

2006-10-02, 7:38 pm

David:

I feel your system would work...
Sometimes I have seen using the \\

Still

I really do not even think of all the thing I would have to
change to use my most important table to do that.
That would be a really major change.
The table is contanly changing, appending, erasing and it
will be a hard work to make it do it.

Also I use other programs (activex) and I do not know if
that would work there.

Still thanks for the idea...
If nothing else works ... then I might have to use it ;)

Thanks
Emilio



> Two different things to try:
>
> 1. Replace the "\" with a "/". If you use all "/"'s, windows will
> accept it, and then it won't be confused by thinking you might be using
> "\" to excape special characters.
>
> 2. Double-up the "\\"'s, so you see "c:\\mythings".
>
>
> --
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).



Ronnie MacGregor

2006-10-02, 7:39 pm


On Mon, 2 Oct 2006 18:02:15 +0200
evilaro said :

> The reason why it does not find the record with applylocate
> is because it contain a \


> Any way around?.


Try feeding your search string through this function first :

function ReplaceBackslash(cText)
// Ronnie MacGregor
local nCount
for nCount = 1 to len(cText)*2 step 2
nPos = at( [\], cText, nCount)
if nPos == 0
exit
else
cText := stuff( cText, nPos, 1, "\\" )
endif
endfor // next
return cText

--
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk



evilaro

2006-10-02, 7:39 pm

Vasile:

It works... but it is slow.

in a table of 33.000 records it takes 2 sec

A little bit tooo much.

But it is a solution...

Please read my solution... maybe it is a work around. ;)

Thanks

Emilio



"Vasile Buza" <hsctm@rdslink.ro> escribió en el mensaje
news:yabhTsk5GHA.1784@news-server...
>
> "evilaro" <buzon[NO]@evilfoto.es> wrote in message
> news:9q7Nw2j5GHA.1156@news-server...
>
> Emilio,
>
> You can try:
>
> private MBUSCAR
>
> MBUSCAR=FORM.ENTRYFIELD1.VALUE.RIGHTTRIM()
> FORM.IMAGENES2.ROWSET.CanGetRow = {|| this.fields["Ctext"].value =
> '&MBUSCAR.' }
> IF FORM.IMAGENES2.ROWSET.first()
> MSGBOX('Found')
> ELSE
> MSGBOX('Not Found')
> ENDIF
>
> Vasile Buza
>
>
>



evilaro

2006-10-02, 7:39 pm

Ronnie:

I am lost...

Do you mean just to change the \ on the searching
text only with a \\

And not all the table with 33.000 records

If this is what you mean, than I did misunderstood the sugestion
of David Kerber

If that is so... it could be a ceptable solution.

Emilio

PS that would mean that SQL will take 2 \\ as one ???





"Ronnie MacGregor" <No_Sp@m.Thanks> escribió en el mensaje
news:MPG.1f8b63cc15ed14c59897a8@news.dbase.com...
>
> On Mon, 2 Oct 2006 18:02:15 +0200
> evilaro said :
>
>
>
> Try feeding your search string through this function first :
>
> function ReplaceBackslash(cText)
> // Ronnie MacGregor
> local nCount
> for nCount = 1 to len(cText)*2 step 2
> nPos = at( [\], cText, nCount)
> if nPos == 0
> exit
> else
> cText := stuff( cText, nPos, 1, "\\" )
> endif
> endfor // next
> return cText
>
> --
> Ronnie MacGregor
> Scotland
>
> Ronnie at
> dBASEdeveloper
> dot co dot uk
>
> www.dBASEdeveloper.co.uk
>
>
>



Ken Mayer [dBVIPS]

2006-10-02, 7:39 pm

evilaro wrote:
> David:
>
> I feel your system would work...
> Sometimes I have seen using the \\
>
> Still
>
> I really do not even think of all the thing I would have to
> change to use my most important table to do that.
> That would be a really major change.
> The table is contanly changing, appending, erasing and it
> will be a hard work to make it do it.
>
> Also I use other programs (activex) and I do not know if
> that would work there.
>
> Still thanks for the idea...
> If nothing else works ... then I might have to use it ;)


Don't change it in the table. Check to see if it exists, and replace "\"
with "\\" in the string you're using:

if "\" $ MBUSCAR
MBUSCAR = stuff( MBUSCAR, at( "\",MBUSCAR ), 1, "\\" )
endif

You might need to put this into a loop if you have multiple backslashes ...

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/dbase/dBASEBook.htm
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
Ronnie MacGregor

2006-10-02, 7:39 pm


On Mon, 2 Oct 2006 20:18:00 +0200
evilaro said :

> I am lost...


You are in Barcelona <g>.


> Do you mean just to change the \ on the searching
> text only with a \\
>
> And not all the table with 33.000 records


Yes, but not in the source location of the source string, you are just changing
it at the eleventh hour to use as your search string.


> If this is what you mean, than I did misunderstood the sugestion
> of David Kerber


Not sure, ask David <g> ... to me his intent is not clear.


> If that is so... it could be a ceptable solution.


Try it and see.


> PS that would mean that SQL will take 2 \\ as one ???


If SQL is interpreting the "\" as a special character (which seems to be your
problem), then the normal solution is to double the character up so that SQL
interprets the "\\" occurrence as - "OK this is not a special character after
all so I will treat the "\\" as a "\" character.


--
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk



evilaro

2006-10-03, 7:23 pm

Ken:

Correct..... as usual............

That is the solution... please see my comment to Ronnie
and David.

Thanks...
It took a while to finf a work around.

Emilio



"Ken Mayer [dBVIPS]" <dbase@_nospam_goldenstag.net> escribió en el mensaje
news:qtfURKl5GHA.1168@news-server...
> evilaro wrote:
>
> Don't change it in the table. Check to see if it exists, and replace "\"
> with "\\" in the string you're using:
>
> if "\" $ MBUSCAR
> MBUSCAR = stuff( MBUSCAR, at( "\",MBUSCAR ), 1, "\\" )
> endif
>
> You might need to put this into a loop if you have multiple backslashes

....
>
> Ken
>
> --
> /(Opinions expressed are purely my own, not those of dataBased
> Intelligence, Inc.)/
>
> *Ken Mayer* [dBVIPS]
> /Golden Stag Productions/
> dBASE at goldenstag dot net
> http://www.goldenstag.net/dbase/dBASEBook.htm
> http://www.goldenstag.net/GSP
> http://www.goldenstag.net/dbase



evilaro

2006-10-03, 7:23 pm

David:

I feel I missunderstood your explanation...

You were leading me to the right direction
but I did not fully understood.

Thanks.. please see my answer to Ronnie...

Now with the changing from \ to \\ it works.

Emilio




"David Kerber" <ns_dkerber@ns_WarrenRogersAssociates.com> escribió en el
mensaje news:MPG.1f8b1280c687185c9896dd@news.dbase.com...
> In article <PAkm3Ik5GHA.1764@news-server>, dbase@_nospam_goldenstag.net
> says...
[C:MYTHINGS ][vbcol=seagreen]
>
> Two different things to try:
>
> 1. Replace the "\" with a "/". If you use all "/"'s, windows will
> accept it, and then it won't be confused by thinking you might be using
> "\" to excape special characters.
>
> 2. Double-up the "\\"'s, so you see "c:\\mythings".
>
>
> --
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).



evilaro

2006-10-03, 7:23 pm


Ronnie


> If SQL is interpreting the "\" as a special character (which seems to be

your
> problem), then the normal solution is to double the character up so that

SQL
> interprets the "\\" occurrence as - "OK this is not a special character

after
> all so I will treat the "\\" as a "\" character.


Yes..... thanks a lot...

That is the solution ... no problem now.



StiLL it is very extrange solution...
And also how anybody on his right mind (not refering to you of course)
could gueSS this aPProach.

I aPPreciate aLL your eFFords.. this solution oPPens
several poSSibilities of improving my EvilFOTO aPPlication.


Do you fEEl I can use it to improve my speLLing ;)

Emilio



David Kerber

2006-10-04, 7:29 pm

In article <9QvYrRv5GHA.1012@news-server>, buzon[NO]@evilfoto.es says...
>
> Ronnie
>
>
> your
> SQL
> after
>
> Yes..... thanks a lot...
>
> That is the solution ... no problem now.
>
>
>
> StiLL it is very extrange solution...
> And also how anybody on his right mind (not refering to you of course)
> could gueSS this aPProach.


I don't know about the other people, but mine was because I've been
running into this issue in my Java work.


> I aPPreciate aLL your eFFords.. this solution oPPens
> several poSSibilities of improving my EvilFOTO aPPlication.
>
>
> Do you fEEl I can use it to improve my speLLing ;)


LOL!


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com