Normal Topic Programming in an ampersand for a search (Read 902 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Programming in an ampersand for a search
Aug 31st, 2006 at 4:14pm
Print Post Print Post  
In my "Customers" database (a list of contacts) I have an element, Checkcode, that combines characters from Company, City and State.  The visibility of Checkcode is set to 0 (not visible) when the user is in Add or Update mode.

For my On-Retreive-Spec-Open event, I have the following code:
Code
Select All
var vCheckcodeLookups as string

// Makes the Checkcode visible for lookups

Visibility(Checkcode, 1)


// Populates the Checkcode combo box

vCheckcodeLookups = @XListValues(@FN, "Customer!Checkcode")
vCheckcodeLookups = @SortstringArray(vCheckcodeLookups,0)
PopulateListElement(Checkcode, vCheckcodeLookups) 



This is working well, giving the user a list and setting the value of the element so all he has to do is press F10 to retrieve the matching Customers.  However...

Many of our customers have an ampersand in their company name, and Sesame balks at retreiving them because of this.  Is there a way to program the retrieve spec so that if the company name includes an ampersand it is ...what's the word?  Allowed?  Literal?  Whatever it is, I think it's a forward slash that needs to be dropped in before the &, but I'm not sure how to go about it.
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programming in an ampersand for a search
Reply #1 - Aug 31st, 2006 at 4:43pm
Print Post Print Post  
Have you tried to replace "&" with "\&"  ?

Code
Select All
vCheckcodeLookups = @XListValues(@FN, "Customer!Checkcode")
vCheckcodeLookups = @Replace(vCheckcodeLookups,"&","\&")
vCheckcodeLookups = @SortstringArray(vCheckcodeLookups,0)
PopulateListElement(Checkcode, vCheckcodeLookups) 



NOTE: Code above is untested, just a quick guess ..... Roll Eyes
==========================================

EDITED COMMENT:  The original posting had "/&" vs. "\&" which Ray pointed out was correct.
Code above has been modified to include correct character.


  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Programming in an ampersand for a search
Reply #2 - Aug 31st, 2006 at 4:46pm
Print Post Print Post  
Quote:
Have you tried to replace "&" with "/&"  ?


\ is the escape character in a search. / means not. So he will want to replace "&" with "\&"

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Programming in an ampersand for a search
Reply #3 - Aug 31st, 2006 at 5:00pm
Print Post Print Post  
Thanks guys, that's the ticket!  Works great.
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programming in an ampersand for a search
Reply #4 - Aug 31st, 2006 at 5:06pm
Print Post Print Post  
I warned you it was untested...... Roll Eyes

I have modified original posting to make it correct.   Thanks Ray!
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged