Hot Topic (More than 10 Replies) Special search characters (Read 1577 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Special search characters
Feb 2nd, 2010 at 2:25pm
Print Post Print Post  
For a long time I've used @Replace() for a field which populate with pieces of a customer record, for use in lookups in other forms, to replace "&" with "\&".  This morning I discovered I need to do it to parentheses as well or Sesame locks up when performing the lookup.

So I dipped into the manuals and learned that I should do it for a bunch of other characters as well.  My current programming looks like this:
Code
Select All
// Populates the Checkcode combo box
IF @MODE() = 2
THEN
	{
	vCheckcodeLookups = @XListValues(@FN, "Customer!Checkcode")
	vCheckcodeLookups = @SortstringArray(vCheckcodeLookups,0)
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "&", "\&")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "(", "\(")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, ")", "\)")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "..", "\.\.")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, ";", "\;")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "/", "\/")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "=", "\=")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, ">", "\>")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "<", "\<")
	vCheckcodeLookups = @Replace(vCheckcodeLookups, "?", "\?")
	PopulateListElement(Checkcode, vCheckcodeLookups)
	} 


Have I missed any special characters?  Thanks for your help.
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Special search characters
Reply #1 - Feb 2nd, 2010 at 3:17pm
Print Post Print Post  
\ - Backslash. Must 1st in list of replacements.

~ - Tilde.

` - Backtick.

] - Right bracket.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Special search characters
Reply #2 - Feb 2nd, 2010 at 3:30pm
Print Post Print Post  
Thanks Carl.  Would this be correct for the backslash?
Code
Select All
vCheckcodeLookups = @Replace(vCheckcodeLookups, "\", "\\") 

  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Special search characters
Reply #3 - Feb 2nd, 2010 at 5:06pm
Print Post Print Post  
Yes.

I've had a list of replacements like this that I've been using for a long time. Your post prompted me to take another look at it, and I've been testing it again. You may also want to add the following character:

[ - Left bracket.


BTW, this character has an interesting behavior that I don't think is documented. You can put it at the beginning of a term in search mode, and it will act as though you placed two dots before and after the term.

So this:

[service call

Works exactly the same as this:
..service call..

It doesn't matter whether or not you place a space after the bracket. You can even leave many spaces between "[" and the term, like this, and it still works:
[     service call
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Special search characters
Reply #4 - Feb 2nd, 2010 at 5:25pm
Print Post Print Post  
Quote:
You may also want to add the following character:

[ - Left bracket.

Got it, thanks.

Quote:
BTW, this character has an interesting behavior that I don't think is documented. You can put it at the beginning of a term in search mode, and it will act as though you placed two dots before and after the term.

Oh, that's lovely, I'll have to remember that one.  Thanks!
  

**
Captain Infinity
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: Special search characters
Reply #5 - Feb 3rd, 2010 at 12:31pm
Print Post Print Post  
OK, so this is what I put together after yesterday's discussion:
Code
Select All
// Populates the Lookup combo box

var vCheckcodeLookups as string

vCheckcodeLookups = @XListValues(@FN, "Customer!Checkcode")
vCheckcodeLookups = @SortstringArray(vCheckcodeLookups,0)
vCheckcodeLookups = @Replace(vCheckcodeLookups, "\", "\\")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "&", "\&")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "(", "\(")
vCheckcodeLookups = @Replace(vCheckcodeLookups, ")", "\)")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "..", "\.\.")
vCheckcodeLookups = @Replace(vCheckcodeLookups, ";", "\;")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "/", "\/")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "=", "\=")
vCheckcodeLookups = @Replace(vCheckcodeLookups, ">", "\>")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "<", "\<")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "?", "\?")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "~", "\~")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "`", "\`")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "[", "\[")
vCheckcodeLookups = @Replace(vCheckcodeLookups, "]", "\]")
PopulateListElement(Pickup_Lookup, vCheckcodeLookups) 


This is working great for things like the parentheses and the ampersand.  However, it is adding a backslash to the end of every redesigned search term.  that is, it is making this:
Quote:
R & M Freight (   8562

into this:
Quote:
R \& M Freight \(   8562\

Clearly the first @Replace is the culprit, but what's the best way to deal with it?

Thanks for your help.
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Special search characters
Reply #6 - Feb 3rd, 2010 at 1:46pm
Print Post Print Post  
It is not because of the first replacement. It is because of you are putting a backslash before each semicolon, and the semicolons are not displayed in the combo box.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Special search characters
Reply #7 - Feb 3rd, 2010 at 1:50pm
Print Post Print Post  
OK, thanks, I think I understand that.  What should I do?  Remove the semicolon @Replace?
  

**
Captain Infinity
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: Special search characters
Reply #8 - Feb 3rd, 2010 at 2:21pm
Print Post Print Post  
Infinity wrote on Feb 3rd, 2010 at 1:50pm:
OK, thanks, I think I understand that.  What should I do?  Remove the semicolon @Replace?


Yes. Because every company name is going to be separated by a semi-colon as they are returned by @XListValues()

-Ray
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Special search characters
Reply #9 - Feb 3rd, 2010 at 2:40pm
Print Post Print Post  
Agree with Ray.


Now, since you are viewing these in a combo box, which is then used for some type of XLU; you could put the backslashes in the value just before the XLU. This way, you don't need to see the backslashes in the combo box.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
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: Special search characters
Reply #10 - Feb 3rd, 2010 at 3:46pm
Print Post Print Post  
Thanks guys.  I'll warn my users not to store semicolons in customer names, and I'll do regular checks to make sure there are none.

As for moving the @Replace routine to just before my XLookups, that's a great idea.  I'll try to get to it soon and let you know how it goes.
  

**
Captain Infinity
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: Special search characters
Reply #11 - Feb 3rd, 2010 at 4:04pm
Print Post Print Post  
I wrote:
Quote:
I'll warn my users not to store semicolons in customer names

I've decided to put in some on-element-change programming that removes them immediately, no sense bugging them about it, they'll never remember anyway and there's always typos.
  

**
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: Special search characters
Reply #12 - Feb 3rd, 2010 at 11:28pm
Print Post Print Post  
Infinity wrote on Feb 3rd, 2010 at 4:04pm:
I wrote:
I've decided to put in some on-element-change programming that removes them immediately, no sense bugging them about it, they'll never remember anyway and there's always typos.

Good idea.  That was my immediate thought when I read your previous idea.  We will probably miss you on Saturday?
  



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