Or if it's a single command, like 'purge', simply use this AppleScript command:
do shell script "purge"
Originally Posted by DavidBlack
YEA but how to hook up the button to the code
The same way you'd do it in any other AppleScript. If you're looking for a tutorial on writing AppleScript and hooking it up to buttons, you should search for that using a search engine like google.
If all you want to do is run the 'purge' command, you don't need a button for that. Enter the command I posted above. Save your AppleScript as an application. To purge memory, launch the application. Every time the application is launched, it purges memory. No button needed/
If you want to do other things, like present a dialog, there are AppleScript commands for that. Google search terms: applescript dialog
If you want a complete window, with multiple buttons, one of which purges memory, and other buttons that do other things, look for a tutorial on making windowed applications with buttons in AppleScript. Everything other than do shell script "purge"
will be common to all such AppleScript apps.