Join Scott Simpson for an in-depth discussion in this video Building functions, part of Learning AppleScript.
…As your script gets longer, it's a good idea to start…grouping code together to stay organized and to keep from repeating yourself.…Adding modularity with functions can help keep your code easy to read, too.…Let's open up a new editor window, and take a look at how functions work.…Functions in AppleScript start with the keyword, on.…On is followed by the name of the command,…followed by a set of parentheses.…Just like you can't have spaces in variable…names, you can't have them in function names either.…In this case, my function is called addNums.…And the definition of the function ends with end and the function name.…That may be a little different than you might expect…since the tell command closes with end tell and if closes with end if.…
You might think the function definition would close…with end on, but that's not how that works.…Of course, functions need to do something.…So, I'll add a line just inside the…function that will run whenever the function is called.…So, having a function defined doesn't really…
- What is AppleScript?
- Using comments, variables, text, and numbers
- Working with files and folders
- Using conditionals and creating loops
- Building functions
- Controlling other programs with AppleScript
- Preventing and catching errors
- Distributing your AppleScript application
Skill Level Beginner
1. Exploring AppleScript
2. Using AppleScript with Applications
3. Your App in the Real World
4. Further Exploration
Folder actions2m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.