Normal Topic Ignoring the semicolon (Read 1309 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Ignoring the semicolon
Nov 22nd, 2010 at 3:27pm
Print Post Print Post  
We have a new user in the company, so of course we're finding new bugs.  The most recent is that she has been including the semicolon when she stores data, and then when other databases do Lookups to her data everything gets shifted a field. (I use @XListValues to group lookup data.)

So I'm looking for a way to lock out the semicolon when users Add or Update a record.  The following works fine to do this:
Code
Select All
 Workorder - On-Form-Entry

// Disables the use of the semicolon in Add or Update mode for non-Admins
IF NOT sGroup = "Admin"
THEN
{
	IF @Mode() = 0 or @Mode() = 1
	THEN
		{
		IgnoreKey(59,0)
		}
	ELSE IF @Mode() = 2
	THEN
		{
		ClearIgnoreKey(59)
		}
} 



However, that last bit, the "Else" to clear the ignore key state when the user is in Mode 2 (Search), does not work.  The ignored key is persistent.

I tried adding this to On-Retrieve-Spec-Open:
Code
Select All
ClearIgnoreKey(59) 


but this also does not clear the persistent ignored state.  What am I overlooking?
  

**
Captain Infinity
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Ignoring the semicolon
Reply #1 - Nov 22nd, 2010 at 4:51pm
Print Post Print Post  
I strongly recommend that you use the SetStringArraySeparator command, instead of turning off any keys.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
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: Ignoring the semicolon
Reply #2 - Nov 22nd, 2010 at 4:57pm
Print Post Print Post  
Hello Scott,

IgnoreKey is probably not going to be the way to do this, as the user can have both Add and Search open at the same time. So if the user opens Add Mode, then opens Search, the semi-colon would work in both Add and Search modes.

What you can do is check the record before it is saved on Form Exit and remove Semi-colons from the field data if there is any.

-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: Ignoring the semicolon
Reply #3 - Nov 22nd, 2010 at 4:58pm
Print Post Print Post  
OK, I'm reading Page 388 now.  Seems pretty straightforward.

But where do I place this command?

If this is the way to go I would like to make it application-wide.  Then the trick is to guess which character my users will never use.  Can I program in a high-bit (off-keyboard) character as the separator?
  

**
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: Ignoring the semicolon
Reply #4 - Nov 22nd, 2010 at 5:00pm
Print Post Print Post  
Quote:
What you can do is check the record before it is saved on Form Exit and remove Semi-colons from the field data if there is any.


Problem is, it could occur in any of dozens of fields, in any of a half-dozen databases which contain lookup-fodder.
  

**
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: Ignoring the semicolon
Reply #5 - Nov 22nd, 2010 at 6:01pm
Print Post Print Post  
OK, until I know better how and where to use the SetStringArraySeparator command, I've think I'll put some cleanup routines into my "Save" buttons.  Since these will run every time a Save button is clicked, even if the cleanup has already occurred, I'm wondering how much the following will slow down my processing time.  Any ideas?
Code
Select All
// Clean semicolons from the data

PICKUP_COMPANY = @REPLACE(PICKUP_COMPANY, ";", ":")
PICKUP_CONTACT = @REPLACE(PICKUP_CONTACT, ";", ":")
PICKUP_ADDRESS = @REPLACE(PICKUP_ADDRESS, ";", ":")
PICKUP_CITY = @REPLACE(PICKUP_CITY, ";", ":")
PICKUP_STATE = @REPLACE(PICKUP_STATE, ";", ":")

DELIVERY_COMPANY = @REPLACE(DELIVERY_COMPANY, ";", ":")
DELIVERY_CONTACT = @REPLACE(DELIVERY_CONTACT, ";", ":")
DELIVERY_ADDRESS = @REPLACE(DELIVERY_ADDRESS, ";", ":")
DELIVERY_CITY = @REPLACE(DELIVERY_CITY, ";", ":")
DELIVERY_STATE = @REPLACE(DELIVERY_STATE, ";", ":")

DESC_LINE_1 = @REPLACE(DESC_LINE_1, ";", ":")
DESC_LINE_2 = @REPLACE(DESC_LINE_2, ";", ":")
DESC_LINE_3 = @REPLACE(DESC_LINE_3, ";", ":")
DESC_LINE_4 = @REPLACE(DESC_LINE_4, ";", ":")
DESC_LINE_5 = @REPLACE(DESC_LINE_5, ";", ":")
DESC_LINE_6 = @REPLACE(DESC_LINE_6, ";", ":")
DESC_LINE_7 = @REPLACE(DESC_LINE_7, ";", ":")
DESC_LINE_8 = @REPLACE(DESC_LINE_8, ";", ":")
DESC_LINE_9 = @REPLACE(DESC_LINE_9, ";", ":") 



I'm assuming that putting a test of each field to see if a semicolon exists there or not would slow things down even more.  Is this assumption correct or do I worry too much over nanoseconds?
  

**
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: Ignoring the semicolon
Reply #6 - Nov 22nd, 2010 at 7:40pm
Print Post Print Post  
OK, I've changed my mind.  Instead of putting the cleaning routine in the Save buttons, I've put it in each element's on-element-change event, so it will only run when necessary.  I've used ThisElement and tossed it into Global code as a subroutine.  Seems to be working well.

I would still like, if Ray, Mark or Erika has a moment or two, some hand-holding with the SetStringArraySeparator command, which I have never used before.  Seems like a nifty bit of code which will solve a lot of problems and will reduce my total code amount when I institute it.  Can it be used in the Application programming?  If not where should it go?  And do you have any advice on which character I should specify as a replacement for the semicolon?  Can I use an accented character from the high-bit set, such as Ě?  If so, how would I specify it in the command?  I've already discovered that the Program Editor doesn't like Ě, so this doesn't work:
Code
Select All
var vNewSep as String = "Ě"
SetStringArraySeparator( vNewSep ) 


which leads me to believe that the high-bit set cannot be used, even if I could figure out how to reference it.  Maybe the pipe symbol | ?  I don't think my users would use that one, but you can never tell, they're a perverse bunch.

OK, I'm starting to ramble; it's past time for my nap.

Thanks for your help.
  

**
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: Ignoring the semicolon
Reply #7 - Nov 22nd, 2010 at 9:32pm
Print Post Print Post  
Hello Infinity,

SetStringArraySeparator() can be used in On Application Open event, just keep in mind that it will switch the Separator from a semi-colon to whatever character you specify application wide. So any commands that use a semi-colon as a separator will need to be switched. So you might want to use if only in an event where you know you're getting data that may have a semi-colon and then set it back after you get the data.

Most people tend to use a pipe '|' or a caret '^' as they don't normally appear in data.

-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: Ignoring the semicolon
Reply #8 - Nov 23rd, 2010 at 2:48pm
Print Post Print Post  
Thanks Ray I'll give it a try!
  

**
Captain Infinity
Back to top
IP Logged