This document is a guide to the AppleScript language—its lexical conventions, syntax, keywords, and other elements. It is intended primarily for use with AppleScript 2.0 or later and macOS version 10.5 or later.
Wirelessly stream videos and photos to Apple TV or a smart TV. Connect to a display with a cable. HomePod and other wireless speakers. Use iPhone with iPad, iPod touch, Mac, and PC. Share your internet connection. Allow phone calls on your iPad, iPod touch, and Mac. Rounds a number away from zero to the nearest multiple of the specified factor. Returns the number of different ways you can combine a number of items into groups of a specific size, ignoring the order within the groups. Rounds a number away from zero to the next even number. How to Establish an Apple Identity on a Mac. When you first turn on your Mac (or install an upgrade to the operating system), a series of questions and prompts appear, including a prompt to sign in to your Apple ID account or create a new Apple ID. MacBook All-in-One For Dummies Cheat Sheet. MacBook owners have a number of tools that come.
AppleScript 2.0 can use scripts developed for any version of AppleScript from 1.1 through 1.10.7, any scripting addition created for AppleScript 1.5 or later for macOS, and any scriptable application for Mac OS v7.1 or later. A script created with AppleScript 2.0 can be used by any version of AppleScript back to version 1.1, provided it does not use features of AppleScript, scripting additions, or scriptable applications that are unavailable in that version.
Important: Descriptions and examples for the terms in this document have been tested with AppleScript 2.0 in OS X v10.5 (Leopard). Except for terms that are noted as being new in Leopard, most descriptions and examples work with previous system versions, but have not been tested against all of them.
If you need detailed information about prior system and AppleScript versions, see AppleScript Release Notes (OS X v10.4 and earlier).
AppleScript is a scripting language created by Apple. It allows users to directly control scriptable Macintosh applications, as well as parts of macOS itself. You can create scripts—sets of written instructions—to automate repetitive tasks, combine features from multiple scriptable applications, and create complex workflows.
Note: Apple also provides the Automator application, which allows users to automate common tasks by hooking together ready-made actions in a graphical environment. For more information, see Automator Documentation.
A scriptable application is one that can be controlled by a script. For AppleScript, that means being responsive to interapplication messages, called Apple events, sent when a script command targets the application. (Apple events can also be sent directly from other applications and macOS.)
AppleScript itself provides a very small number of commands, but it provides a framework into which you can plug many task-specific commands—those provided by scriptable applications and scriptable parts of macOS.
Most script samples and script fragments in this guide use scriptable features of the Finder application, scriptable parts of macOS, or scriptable applications distributed with macOS, such as TextEdit (located in /Applications).
You should use this document if you write or modify AppleScript scripts, or if you create scriptable applications and need to know how scripts should work.
AppleScript Language Guide assumes you are familiar with the high-level information about AppleScript found in AppleScript Overview.
This guide describes the AppleScript language in a series of chapters and appendixes.
The first five chapters introduce components of the language and basic concepts for using it, then provide additional overview on working with script objects and handler routines:
AppleScript Lexical Conventions describes the characters, symbols, keywords, and other language elements that make up statements in an AppleScript script.
AppleScript Fundamentals describes basic concepts that underly the terminology and rules covered in the rest of this guide.
Variables and Properties describes common issues in working with variables and properties, including how to declare them and how AppleScript interprets their scope.
Script Objects describes how to define, initialize, send commands to, and use inheritance with script objects.
About Handlers provides information on using handlers (a type of function available in AppleScript) to factor and reuse code.
The following chapters provide reference for the AppleScript Language:
Class Reference describes the classes AppleScript defines for common objects used in scripts.
Commands Reference describes the commands that are available to any script.
Reference Forms describes the syntax for specifying an object or group of objects in an application or other container.
Operators Reference provides a list of the operators AppleScript supports and the rules for using them, along with sections that provide additional detail for commonly used operators.
Control Statements Reference describes statements that control when and how other statements are executed. It covers standard conditional statements, as well as statements used in error handling and other operations.
Handler Reference shows the syntax for defining and calling handlers and describes other statements you use with handlers.
The following chapter describes an AppleScript-related feature of macOS:
Folder Actions Reference describes how you can write and attach script handlers to specific folders, such that the handlers are invoked when the folders are modified.
The following appendixes provide additional information about the AppleScript language and how to work with errors in scripts:
AppleScript Keywords lists the keywords of the AppleScript language, provides a brief description for each, and points to related information.
Error Numbers and Error Messages describes error numbers and error messages you may see in working with AppleScript scripts.
Working with Errors provides detailed examples of handling errors with try Statements and error Statements. Apple laptop back view.
Double Angle Brackets describes when you are likely to see double angle brackets (or chevrons—«») in scripts and how you can work with them.
Libraries using Load Script describes how to save libraries of handlers and access them from other scripts.
Unsupported Terms lists terms that are no longer supported in AppleScript.
Glossary terms are shown in boldface where they are defined.
Important: This document sometimes uses the continuation character (¬) for sample statements that don’t fit on one line on a document page. It also uses the continuation character in some syntax statements to identify an item that, if included, must appear on the same line as the previous item. The continuation character itself is not a required part of the syntax—it is merely a mechanism for including multiple lines in one statement.
The following conventions are used in syntax descriptions:
language element | Plain computer font indicates an element that you type exactly as shown. If there are special symbols (for example, + or &), you also type them exactly as shown. |
placeholder | Italic text indicates a placeholder that you replace with an appropriate value. |
[optional] | Brackets indicate that the enclosed language element or elements are optional. |
(a group) | Parentheses group elements together. However, the parentheses shown in Handler Syntax (Positional Parameters) are part of the syntax. |
[optional].. | Three ellipsis points (..) after a group defined by brackets indicate that you can repeat the group of elements within brackets 0 or more times. |
a | b | c | Vertical bars separate elements in a group from which you must choose a single element. The elements are often grouped within parentheses or brackets. |
Filenames shown in scripts | Most filenames shown in examples in this document include extensions, such as rtf for a TextEdit document. Use of extensions in scripts is generally dependent on the “Show all file extensions” setting in the Advanced pane of Finder Preferences. To work with the examples on your computer, you may need to modify either that setting or the filenames. |
These Apple documents provide additional information for working with AppleScript:
See Getting Started with AppleScript for a guided quick start, useful to both scripters and developers.
See AppleScript Overview, including the chapter Scripting with AppleScript, for a high-level overview of AppleScript and its related technologies.
See Getting Started With Scripting & Automation for information on the universe of scripting technologies available in macOS.
See AppleScript Terminology and Apple Event Codes for a list of many of the scripting terms defined by Apple.
For additional information on working with the AppleScript language and creating scripts, see one of the comprehensive third-party documents available in bookstores and online.
Copyright © 2016 Apple Inc. Macbook pro mac os x. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2016-01-25
Home > Articles > Apple > Operating Systems
Numbers is a spreadsheet application that benefits from tight integration with the other Apple productivity applications, Pages and Keynote. Numbers is available on OS X for Mac, iOS for the iPad and iPhone, and via web browsers.
This article provides 10 tips for Numbers, highlighting ideas and functions that will help boost your productivity, but some of the advice is also applicable to Pages and Keynote. For example, Pages and Keynote can create tables and charts similar to those created in Numbers; however, for extra control over your data, you should create tables and charts in Numbers and then copy them into Pages and Keynote as needed.
Numbers documents can contain multiple sheets, each of which can be used as a blank canvas on which to add tables and charts. You might have expected these features; however, users often overlook the ability to add media such as photos or video. For example, when documenting a school's science lab experiment, adding photos and video of the processes involved could make for a visually rich presentation.
Figure 1 shows an example of a father and son's efforts to research facts about World War II. The charts and tables in Numbers were copied and pasted into Pages and Keynote for class presentations. Notice the size of the spreadsheet in Numbers; it offers plenty of space for adding special features to the research documentation.
Figure 1. The spreadsheets in Numbers are vast. Much of the text here is set in 10 pt, and the selected photo measures 6 × 5 inches.
Other types of spreadsheets might include business fact-finding, vacation planning, and so on. By adding screen grabs of websites or photos of the products or places you're researching, you can use Numbers as a number-crunching pin-board.
Numbers lets you add tables to a sheet with ease. Where appropriate, however, break up calculations into multiple tables to make navigating your spreadsheet easier (see Figure 2).
Figure 2. Organize your data into multiple tables.
Using smaller tables also helps to isolate any math problems in complex calculations. These concepts are explored further in Lesson 10, 'Making Customized Calendars,' in Apple Pro Training Series: Pages, Numbers, and Keynote. The lesson also explains the syntax for creating advanced formulas, which can lead to spreadsheets that work as mini-applications. The example shown in Figure 2 is a photographer's price calculator for prints. The spreadsheet can be used to choose a variety of paper types, sizes, and qualities, quickly returning a price that the photographer can quote to her clients.
It's a good habit to rename tables and charts as you create them in Numbers. Suppose you create multiple tables, as suggested in Tip 2. If you don't rename them, you'll be confronted with the default references (Table 1, Table 2, Table 3, and so on) when you try to apply formulas.
In Figure 3, the table has been renamed Price Calculator. The Inspector shows that the Table Name option is enabled. If this option were deselected, the table would still be identified in the Formula Editor as Price Calculator, but the label on the sheet would disappear.
Figure 3. Labeling tables and charts descriptively is a best practice.
In the same vein, when the sheet tab is clicked. a menu appears, listing all the tables and charts on that sheet. Notice in Figure 4 that the tables are labeled as Price Calculator and Paper Prices. Having descriptive labels helps you to find and jump to the required table or chart more easily than with the default table names of Table 1, Table 2, and so forth.
Figure 4. Here the Sheet menu lists two tables: Price Calculator and Paper Prices.
Numbers will try to guess which data format to use, depending on what you type into a cell. Often Numbers will guess correctly, but sometimes you'll want to set the data format manually (see Figure 5).
Figure 5. Numbers automatically chooses cell data formats, but sometimes you'll need to set the format manually.
The Numbers application's guesswork can be a great time saver, too. In Figure 6, I typed Monday into cell A1 and then dragged across the adjacent columns. Numbers automatically added the remaining days of the week.
Figure 6. The combination of Numbers' guesswork and autofill is a great time-saver for filling in days of the week, months of the year, dates, or number sequences.
To explore formatting in more detail, see Apple Pro Training Series: Pages, Numbers, and Keynote.
Numbers has five interactive data formats: Checkbox, Star Rating, Slider, Stepper, and Pop-Up Menu. Often, one of these formats will be the ideal solution for data input. For example, use Pop-Up Menu to create a custom list of items from which users can select, or use Slider to quickly apply a number value in a range of your choosing.
The example in Figure 7 comes from Lesson 9, 'Making Interactive Spreadsheets,' in Apple Pro Training Series: Pages, Numbers, and Keynote. A pop-up menu is configured to show all the junior grading levels for a Kempo Ju-Jitsu club. The lead instructor only has to click a student's grade, and a custom pop-menu appears.
Figure 7. Creating pop-up menus speeds up data input.
Staying with the Ju-Jitsu club, Figure 8 shows a range of interactive data formats in a grading assessment table. Checkboxes are used for the first five assessment criteria, but for the training bouts Star Ratings have been set for qualitative assessment.
Figure 8. Use the interactive data formats to make data input intuitive and more accurate.
You can apply this idea to a wide range of assessment types, and not just in education or sports—perhaps in medical or engineering assessments, etc.
For users taking their first steps with spreadsheets, setting up calculations is a great achievement. The default reference settings work well in many cases, but changing the cell references unlocks a world of possibilities.
Earlier I mentioned Lesson 10 in the book. The lesson begins with an exercise to construct a multiplication table. For the math to work correctly, the cell references have to be changed from the default settings. In Figure 9, cell F4 calculates 5 × 4. To achieve this result, the references to row 1 and column A must be preserved, as shown in Figure 10. (If you work through Lesson 10, these concepts will be clearer.)
Figure 9. The formula in cell F4 shows that cells F1 and A4 are being referenced. Numbers' default referencing would show cells F3 and E4 in the Formula Editor, so the default referencing wouldn't work for this multiplication table example.
Figure 10. Clicking a reference in the Formula Editor opens a pop-up menu in which you can change the cell referencing.
The inquiring mind will dare to imagine great things from spreadsheets. Understanding the options for referencing cells in formulas will have you moving forward by leaps and bounds.
This tip applies to Keynote and Pages, too. All three applications automatically save your documents as you work. This feature removes the need to remember to save your work periodically, but here's one reason why you still might want to save manually. Imagine a scenario where you've reached a point of perfection; your spreadsheet, essay, or slideshow is dazzlingly brilliant, but you want to try to take things further. Choose File > Save or press Command-S to save that specific version of your document. You can save as many versions as you like (see Figure 11).
Later, if you want, you can use Revert To options to restore that point of perfection. Find the revert options by choosing File > Revert To. A window appears that looks and behaves much like OS X Yosemite's Time Machine.
Figure 11. Restoring a version of a Pages, Numbers, or Keynote document opens a window very much like OS X Yosemite's Time Machine.
The versions of Pages, Numbers, and Keynote on your Mac are heavy hitters amid the other versions of the applications on iOS and iCloud. To make the most of the portable convenience of your iPad or iPhone, and the seamless integration of Numbers across the ecosystem of Apple products, design your spreadsheet on your Mac. Save the spreadsheet to iCloud so that you can test your design on your iPad or iPhone, and then continue refining the spreadsheet on your Mac until the design also displays neatly on your iOS device (see Figure 12).
Figure 12. The grading spreadsheet looks almost identical on iOS and OS X. (Compare Figure 12 with Figure 8.)
Of course, you can develop spreadsheets exclusively on your iOS device, but the OS X version has additional features you may find useful.
Stepping away from the OS X version of Numbers, this tip offers a great benefit for anyone entering data on an iPad or iPhone. As Tip 8 suggests, developing your spreadsheet on a Mac is likely to be the best option, but one feature in Numbers is only found in the iOS version. As you tap the plus (+) icon to create a new sheet in the iOS version of Numbers, you get two options: New Sheet or New Form (see Figure 13).
Figure 13. The Form options in Numbers for iOS are accessed via the plus (+) sign adjacent to the sheets.
Forms are based on existing tables and make data entry a cinch. Figure 14 shows the Junior Register table from Figure 12 in Form view. The image was captured on an iPad Mini, and even with the smaller screen size you can see that plenty of space is available to navigate through the register.
The interactive data formats are also available in Form view, as shown in Figure 15.
Figure 15. Movie maker apple mac. Interactive data formats are accessible in Form view.
Spreadsheets often contain sensitive information, whether that's product pricing, personnel details, or a record of all the shopping you've done. Locking down a spreadsheet is not just prudent—it may be necessary to comply with data protection laws. Applying password protection is easy, and the same process is used for Keynote and Pages: Just choose File > Set Password, and enter your password in the required fields.
We've reached the end of our brief look at getting the most out of Numbers. Apple Pro Training Series: Pages, Numbers, and Keynote. explores these concepts in greater depth, with exercises based on real-world scenarios to help you consolidate your learning.