Saving As "Compiled"
To use the script from iTunes Scripts Menu save it as a compiled script. A compiled script is one that has the proper syntax and whose commands work properly on your computer but it is not a free-standing application. It can only be run by Script Editor or an application like iTunes that has a script interpreter. (In the next section you will see how to save scripts as applications so that you can run them from the desktop or as bundles which run as universal binaries that run natively on either PowerPC or Intel Macs.)
Click on File > Save As.... Enter the name for your script. We won't be very creative here; name the script "Play Top 25 Most Played Playlist"—without the quotes, of course. Next, in the File Format pop-up of the Save dialog select "Script", which is the default format anyway. AppleScripts for iTunes should be saved in iTunes' "Scripts" folder, [username]/Library/iTunes/Scripts/. Navigate to this folder. If there is no "Scripts" folder there, create one. Click the "Save" button. The script should now be available in iTunes Scripts Menu. Try it!
Basic Debugging
No matter how well you know your AppleScript syntax you will make errors writing a script. Checking a script to make sure it works correctly is called debugging—removing the bugs. Script Editor has a couple of features that will help you observe how a script is working so that you can trap errors and problems better, thus eliminating a lot of the guess-work (although there's a lot of guess-work that goes on, too).
First you will want to be able to see the result of any script actions, so click on the Result tab. (In older Script Editors, select the Controls > Show Result.) You can resize this window so that you have easy visual access to it while working on your script in the main Script Editor window. The Result Window always displays the last result from the Script Window.
To see how a script is interpretted by AppleScript as it's running, click the Event Log tab. (In older Script Editors it's Controls > Open Event Log and check both the "Show Events" and "Show Event Results" boxes.) When you Run a script from Script Editor the Event Window will display each command as it's understood by AppleScript and each result (when available). This is particularly helpful in refining your syntax, or figuring out where a bad script has gone wrong.
Ready to cook! The Event Window shows the events your script performed when it was run.
Next, you will see other ways to save your script...