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
formatting in text entry field.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
there's many ways to skin a cat, but these are what i just came up with:
or maybe:
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
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
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
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.
[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.
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?
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?