case dialog.yesNoCancel ("Save changes before quitting?")
1
msg ("Your changes are being saved...")
fileMenu.save ()
2
msg ("Your changes are being discarded...")
3
msg ("Ok, we won't quit")
return (false) // don't continue process
fileMenu.quit ()
Type this script into a script window. In this example, dialog.yesNoCancel is known to return a result of 1, 2 or 3. The case statement allows the appropriate action to be taken for each response.
case user.initials
"DW"
msg ("Hi Dave!")
"dmb"
msg ("Yo Doug!")
else
msg ("Howdy stranger.")
Type this script into a script window. This example demonstrates the use of the else clause, and also illustrates a feature of the case statement that is unlike most other languages: the case expression and the item expressions can work with values of any type.
case itemhit
1 // user clicked OK
copyfromdialog ()
return (false)
2 // user clicked Cancel
return (false)
3
5
checkboxhit (itemhit)
6
7
8
radiobuttonhit (itemhit)
This is just a script fragment, so don't attempt to execute it. It shows how the same statements can be shared by several item expressions by listing them in sequence and including the statements only under the last item.