Accessibility
 
Home > Products > Director > Support > Lingo, Behaviors and Parent Scripts
Macromedia Director Support Center - Lingo, Behaviors and Parent Scripts
How the example works

Send checkNumber message
You click the Enter button and its Send Message behavior sends the following sendAllSprites message to the Display Field sprite:

sendAllSprites(#checkNumber)

Check the text
The Display Field sprite's Check Number behavior checks the entered text for several error conditions in the following if...then statement:

set errorFound to #none

if testString contains " " then
    set errorFound to #spaces
  else
    if length(testString) > 5 then
      set errorFound to #tooLong
    else
      if length(testString) < 5 then
        set errorFound to #tooShort
      else
        if voidP(value(testString)) then
          set errorFound to #notNumber
        end if
      end if
    end if
  end if

Display an error alert
The case statement displays an error alert, depending on the error conditions found in the if...then statement that sets the symbol in errorFound .

case errorFound of
    #none:      alert "This is a valid zip code."
    #spaces:    alert "A zip code can not contain spaces."
    #tooLong:   alert "A zip code can't have more than 5 digits."
    #tooShort:  alert "A zip code can't have less than 5 digits."
    #notNumber: alert "A zip code contains only numbers"
  end case