Page 1 of 1
formatting in text entry field.
Posted: Wed Mar 26, 2008 8:53 pm
by keyless
I have a text entry field for the entry of a series of 3 digit numbers.
I want to make it so a space is created automatically betweeb the 3 digits when the user types in the numbers.
example: 123 456 789 101 112
Posted: Thu Mar 27, 2008 12:59 am
by BvG
there's many ways to skin a cat, but these are what i just came up with:
Code: Select all
on rawKeyUp
put the text of me into theText
replace space with "" in theText
if the number of chars theText mod 3 = 0 then
put space after theText
end if
end rawKeyUp
or maybe:
Code: Select all
on rawKeyUp
put the text of me into theText
replace space with "" in theText
put 0 into x
put "" into theResult
repeat for each char theChar in theText
add one to x
if x mod 3 = 0 then
put theChar & space after theResult
else
put theChar after theResult
end if
end repeat
put theResult into me
end rawKeyUp
Posted: Thu Mar 27, 2008 4:27 am
by keyless
Error on the first code
[Type] if: missing 'then'
[Object] archieves
[Line] if the number of chars theText mod 3 = 0 then
[Hint] of
The second code causes the text to type in from right to left and doesn't space properly at all.
I see where you are going with the first one, I'll try playing around with that when I get a chance. I think it should be 'chars in theText' and I'm not seeing any line that puts the evaluated back into the field.
Posted: Thu Mar 27, 2008 5:17 am
by keyless
I played with the first code a little.
It does work after I add the missing 'in' and change the last theText to me.
But the behavior of the backspace and delete key when used in the field makes it less then optimal (it causes courser to move ahead erratically.
perhaps a one line table field could be used, where each column is only 3 characters?