To avoid errors, add code to the Script Editor scripting pane by double-clicking an object in the Object browser or by cutting and pasting rather than by typing.