Normal Topic best way to check restricted characters (Read 1292 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
best way to check restricted characters
Mar 13th, 2012 at 6:00am
Print Post Print Post  
The restricted characters such as ";",  "!", etc can mess up the programming routines especially ";" and all stringarray commands. What is the best way to way prevent entering them while inputting data as well as warning when it has been done? Instead of checking and coding individual fields, there must be a way to do that with a simple one line command, preferably right when the mistake is committed! Particularly ";" key is a regular key near "L" and one need not use the shift key to input it, mistake could easily be typo error.  Any thoughts?
  
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: best way to check restricted characters
Reply #1 - Mar 13th, 2012 at 4:24pm
Print Post Print Post  
Make a global string of "problem" chars.  Create a sub routine that checks InString, and does a Replace command if InString is true.  Put the call to the subroutine in OnImmediateChange trigger for those fields where this is a concern.
  



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


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: best way to check restricted characters
Reply #2 - Mar 13th, 2012 at 5:01pm
Print Post Print Post  
Thanks Bob. I was thinking more in terms of on form change event that is way avoid placing a code in individual elements. What about Universal Event or something? On Immediate change will have too many triggers and likely to slow down the system... I think.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: best way to check restricted characters
Reply #3 - Mar 13th, 2012 at 5:21pm
Print Post Print Post  
What about just testing it out on Exit Event of the form? How do I check practically all the fields?
  
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: best way to check restricted characters
Reply #4 - Mar 14th, 2012 at 4:10am
Print Post Print Post  
I think that anything checking all fields will probably have a speed impact.  That was why I suggested only using it on necessary elements.  It might also be necessary to notify users of replacements so they can use an alternative char, unless you can create an automatic replacement char when using Replace, to actually replace and not just remove.

I think you can also kill certain keyboard keys, turn on when in Add/Modify mode, and turn off when no in that mode, allowing normal use of the keys.

(Only have time to shoot some brainstorm ideas without code right now....)
  



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


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: best way to check restricted characters
Reply #5 - Mar 14th, 2012 at 6:29am
Print Post Print Post  
Thanks Bob for your feedback. This little code On Form Exit Event will do the trick. I use vRestrictedCharacerIndicator with Notify (1) to prevent saving the record. It works great. It works instantly and does not use much resources.  Moreover, it is a generic code and it can be used with any form. One can add more restricted characters as needed but I am right now more concerned about ";".

Code
Select All
var vTotal as Int 
var vlist as string = @stringArrayElementList( )
var n as Int
var vName as String
var vDataElementString as String
var vRestrictedCharacerIndicator as int


vTotal = @NumberofElements( )

While n <= vTotal
	{
		vName = @AccessStringArray (vList, n)
			SetThisElement (vName)

			If @ElementBoundToType (ThisElement) = 6 then
			{
				If @IN (ThisElement, ";") > 0 then
					{
						WriteLN ("Please remove " + "; " + "from " + vName )
						n = vTotal  //ends the loop
						vRestrictedCharacerIndicator = 1

					}
					Else
					{
						vRestrictedCharacerIndicator = 0

					}

			}
		UnSetThisElement ( )

		n = n + 1
	}
 

  
Back to top
 
IP Logged