Focal Point
Searching for a string havaing an ampersand

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5251018331

November 28, 2004, 11:05 AM
<Kalyan>
Searching for a string havaing an ampersand
Hi,
I have a report which would allow the user to search for names. I am not able to use any search strings having "&" character in it.
eg:if I search for johnson & johnson the procedure assumes that there is a variable &johnson.... Is there any way in which I can use any escape character to handle this? I tried using \ as an escape char and also single quotes but it did not work. Could any one share with me the trick to do this?????
November 28, 2004, 05:28 PM
GCohen
If there is a space after the &er it should not be treated as a special character.e.g.
WHERE STORE EQ 'A & P' ;

If there is no space after, then the escape character before a quoted value is needed. e.g.

WHERE STORE EQ 'A \"P" ' ;

When the string is picked up on a form, the & is just another character. e.g.
WHERE STORE EQ '&MYSTORE' ;
and the value supplied for MYSTORE is A & P .
November 28, 2004, 05:29 PM
GCohen
sorry the escape example is..
WHERE STORE EQ 'A \"&"P '
November 29, 2004, 02:03 AM
susannah
IF CUST_NAME CONTAINS 'JOHNSON &| JOHNSON'
works like a charm.
The pipe character | is the escape character for the &
(we're in win2k, ie, and webfocus 525)
November 29, 2004, 02:42 AM
<Kalyan>
That's great!!! Both the suggestions work ..
Thanks a lot.
December 08, 2004, 07:10 PM
<susanswanger>
I'm having the same problem but my drop down list of selections for &MyStore is being pulled from a list of stores in the Database so how do I replace A&P with A|&P when passing it in? A & P (with the space before the & )does not work it gave me the same error. I don't want to change the name to A and P. Can any one help?
December 09, 2004, 01:25 AM
<Kalyan>
I guess you are trying to pass the value A&B through a URL.. if that is the case even if you add a pipe symbol before ampersand FOCUS will assume &B as a separate amper variable.

I had a similar problem but I solved it by sending the ascii equivalent of & in the URL. The ascii equivalent is %26

eg: http://yourwebfocusserver?IBIAPP_app=yourfexdirectory&I...=yourfex¶m=A%26B

Hope this helps.

Kalyan.
December 09, 2004, 04:42 PM
<susanswanger>
Well thanks but I have no idea how to do that. I'm new to Webfocus and I'm using the Resource Layout Painter to create the HTML. Frankly I find plain old ASP with an ODBC connection much easier and much more forgiving.