PDA

View Full Version : Example: Remove Spaces - Input object


Intrigued
08-13-2006, 06:02 PM
The following is code that will allow for the "real-time" removal of spaces in an Input object.

Note: Change the Input object names as needed

Add this code to the On Key of the intended Input object.

--The number '32' equals the ASCII Decimal SPACE
if e_Key == 32 then
strInput1 = Input.GetText("Input1")
strInput1 = String.Replace(strInput1, " ", "", false)
strInput1Length = String.Length(strInput1)
Input.SetText("Input1", strInput1)
Input.SetSelection("Input1", strInput1Length+1, strInput1Length+1)
end

Here is an exported project file, example:

http://www.amsuser.com/ams/examples/InputValidate-AMS6-Intrigued.apz

Mikhail
11-14-2006, 07:45 PM
The following is code that will allow for the "real-time" removal of spaces in an Input object.

Note: Change the Input object names as needed

Add this code to the On Key of the intended Input object.



Thanks! Another version:


--The number '32' equals the ASCII Decimal SPACE
if e_Key == 32 then
strCache = Input.GetText(this);
local strCache = String.Replace(strCache, " ", "", false);
local strCacheLength = String.Length(strCache);
Input.SetText(this, strCache);
Input.SetSelection(this, strCacheLength + 1, strCacheLength + 1);
end