numbers only field

Malte Brill malte.brill at t-online.de
Tue Sep 2 05:49:01 EDT 2003


o.k I´m getting slow. :-)

I only want to post this as an addition to Klaus script. It also allows
negative numbers. It puts 0. into the field if it is empty and the period
key is pressed.

In the fields script:

on keydown theKey
  if theKey is in "1234567890" then
     pass keydown
  end if
  if theKey="." and "." is not in me then
    if me is empty or the number of chars of me=1 and char 1 of me="-" then
      put "0." after me
    else
      pass keydown
    end if
  end if
  if theKey="-" then
    if me is empty then
      pass keydown
    else
      if the first char of me <>"-" then
        put "-" before the first char of me
        put "" after the last char of me
      else
        put "" into the first char of me
        put "" after me
      end if
    end if
  end if
end keydown 

regards,

Malte




More information about the use-livecode mailing list