Ensuring numeric input
Michael J. Lew
michaell at unimelb.edu.au
Thu Oct 27 21:24:22 EDT 2005
Thank you all for your input into my problem. I have now settled on a
solution using a combination of a keydown filter and a handler
triggered on closeField.
In the field scripts:
on keydown thekey
if theKey is in "01234567890-.," then --note comma added for MisterX
pass keyDown
end if
end keydown
on closeField
checkFieldForValidNumbers(the id of me)
end closeField
And in the stack script:
on checkFieldForValidNumbers pfieldID
put fld ID pFieldID into tdata
put 0 into lineNum
repeat for each line tline in tdata
add 1 to lineNum
if tline is not a number then
beep
Answer "Please ensure that all values are valid numbers."
select line lineNum of field id pFieldID
exit to top
end if
end repeat
end checkFieldForValidNumbers
I am assuming that the number() function will be OK with commas as
decimal places in coutries where that is the norm, but I'm not really
sure. Xavier, can you check that the scripts work OK for you please?
--
Michael J. Lew
Senior Lecturer
Department of Pharmacology
The University of Melbourne
Parkville 3010
Victoria
Australia
Phone +613 8344 8304
**
New email address: michaell at unimelb.edu.au
**
More information about the use-livecode
mailing list