<!DOCTYPE html>
<html lang="en">
<head>
<title>Class Reference</title>
<meta http-equiv="X-UA-Compatible" content="IE=7">
<meta charset="utf-8">
<meta id="book-resource-type" name="book-resource-type" content="Guide">
<meta scheme="apple_ref" id="identifier" name="identifier" content="//apple_ref/doc/uid/TP40000983">
<meta id="document-version" name="document-version" content="5.2.0">
<meta id="build" name="build" content="c1e4c7a89af8f899a21cfa81fc33ba42" />
<meta id="chapterId" name="chapterId" content="TP40000983-CH1g">
<meta id="date" name="date" content="2016-01-25">
<meta id="description" name="description" content="Defines the AppleScript scripting language. Includes many brief sample scripts.">
<meta id="book-title" name="book-title" content="AppleScript Language Guide">
<meta id="book-root" name="book-root" content="../">
<meta id="book-json" name="book-json" content="../book.json">
<meta id="devcenter" name="devcenter" content="Mac Dev Center">
<meta id="devcenter-url" name="devcenter-url" content="http://developer.apple.com/devcenter/mac">
<meta id="reflib" name="reflib" content="Documentation Archive">
<meta id="book-assignments" name="book-assignments" content="{Type/Guide}, {Topic/Languages & Utilities/Other Languages}">
<meta id="copyright" name="copyright" content="Copyright 2018 Apple Inc. All Rights Reserved.">
<meta id="xcode-display" name="xcode-display" content="render">
<meta id="IndexTitle" name="IndexTitle" content="AppleScript Language Guide: Class Reference">
<meta id="resources-uri" name="resources-uri" content="../../../../../Resources/1282">
<link id="book-index-page" rel="Start" title="AppleScript Language Guide" type="text/html" href="../index.html">
<link id="next-page" rel="Next" type="text/html" href="ASLR_cmds.html">
<link id="previous-page" rel="Prev" type="text/html" href="../conceptual/ASLR_about_handlers.html">
<link rel="stylesheet" type="text/css" href="../../../../../Resources/1282/CSS/screen.css">
<!-- xcode_css -->
<link rel="stylesheet" type="text/css" href="../../../../../Resources/1282/CSS/feedback.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta id="platforms" name="platforms" content="">
</head>
<body><a name="//apple_ref/doc/uid/TP40000983-CH1g" title="Class Reference"></a>
<div id="_omniture_top">
<!-- SiteCatalyst code version: H.8. Copyright 1997-2006 Omniture, Inc. -->
<script type="text/javascript">
/* RSID: */
var s_account="awdappledeveloper"
</script>
<script type="text/javascript" src="https://developer.apple.com/assets/metrics/scripts/analytics.js"></script>
<script type="text/javascript">
s.channel="www.documentationarchive.developer"
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)</script>
<!-- End SiteCatalyst code version: H.8. -->
</div>
<div id="adcHeader" class="hideOnPrint hideInXcode">
<div id='ssi_Header' class="hideInXcode unified">
<a id="ssi_LibraryTitle" href='../../../../../navigation/'>Documentation Archive</a>
<a id="ssi_AppleDeveloperConnection" href='https://developer.apple.com/'>Developer</a>
<div id='ssi_SearchButton' role="button" title="Search">Search</div>
</div>
<form id='ssi_SearchMenu' method='get' action='../../../../../search/' accept-charset='utf-8'>
<label for='adcsearch'>Search Documentation Archive</label>
<input type='search' id='ssi_SearchField' name='q' accesskey='s' results='5' />
</form>
</div>
<header id="header">
<div id="title" role="banner">
<h1>AppleScript Language Guide</h1>
<span id="file_links">
<a id="PDF_link" role="button" tabindex='4' rel="alternate" title="Download PDF"><span id="pdf_icon"></span>PDF</a>
<a id="Companion_link" role="button" tabindex='3' title="Download Companion File"><span id="companion_icon"></span>Companion File</a>
</span>
</div>
<ul id="headerButtons" class="hideOnPrint" role="toolbar">
<li id="toc_button" style="display:none">
<button tabindex="5" id="table_of_contents" class="open" role="checkbox" aria-label="Show Table of Contents"><span class="disclosure"></span>Table of Contents</button>
</li>
<li id="jumpto_button" style="display:none" role="navigation"><select tabindex="6" id="jumpTo"><option value="top">Jump To…</option></select></li>
<li id="downloadSample_button" style="display:none">
<a id="Sample_link"><button id="Sample_button">Download Sample Code</button></a>
</li>
</ul>
</header>
<nav id="tocContainer" tabindex="7">
<ul id="toc" role="tree"></ul>
</nav>
<article id="contents" tabindex="0" role="main">
<div id="pageNavigationLinks_top" class="pageNavigationLinks">
<a class='nextLink' rel='next' href='ASLR_cmds.html'>Next</a><a class='previousLink' rel='prev' href='../conceptual/ASLR_about_handlers.html'>Previous</a>
</div>
<a id="top" name="top"></a>
<a id="INDEX" href="../index.html" style="display:none;"></a>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-246384" title="Class Reference"></a><h1 id="pageTitle">Class Reference</h1>
<p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_528"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_529"></a>A <em class="newTerm">class</em> is a category for objects that share characteristics. AppleScript defines classes for common objects used in AppleScript scripts, such as aliases, Boolean values, integers, text, and so on.</p><p>Each object in a script is an instance of a specific class and has the same properties (including the <code>class</code> property), can contain the same kinds of elements, and supports the same kinds of operations and coercions as other objects of that type. Objects that are instances of AppleScript types can be used anywhere in a script—they don’t need to be within a <code>tell</code> block that specifies an application.</p><p>Scriptable applications also define their own classes, such as windows and documents, which commonly contain properties and elements based on many of the basic AppleScript classes described in this chapter. Scripts obtain these objects in the context of the applications that define them. For more information on the class types applications typically support, see “Standard Classes” in Technical Note TN2106, <span class="content_text"><a href="http://developer.apple.com/technotes/tn2002/tn2106.html" class="browserLink" >Scripting Interface Guidelines</a></span>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW3" title="alias"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_530"></a><div class="content_ref_head_code">alias</div><p>A persistent reference to an existing file, folder, or volume in the file system.</p><p>For related information, see <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW17" data-renderer-version="1">file</a></code>, <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW15" data-renderer-version="1">POSIX file</a></code>, and <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW28" data-renderer-version="1">Aliases and Files</a></span>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW4" title="Properties of alias objects"></a><h5>Properties of alias objects</h5><table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_531"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value is always <code>alias</code>.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_532"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>POSIX path</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The POSIX-style path to the object.</td></tr></table><br/><br/><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_16" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>AppleScript supports coercion of an <code>alias</code> object to a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object or single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_17" title="Examples"></a><h5>Examples</h5><div class="codesample clear"><table><tr><td scope="row"><pre>set zApp to choose application as alias -- (then choose Finder.app)<span></span></pre></td></tr><tr><td scope="row"><pre>--result: alias "Leopard:System:Library:CoreServices:Finder.app:"<span></span></pre></td></tr><tr><td scope="row"><pre>class of zApp --result: alias<span></span></pre></td></tr><tr><td scope="row"><pre>zApp as text --result: "Leopard:System:Library:CoreServices:Finder.app:"<span></span></pre></td></tr><tr><td scope="row"><pre>zApp as list --result: {alias "Leopard:System:Library:CoreServices:Finder.app:"}<span></span></pre></td></tr></table></div><p>You can use the <code>POSIX path</code> property to obtain a POSIX-style path to the item referred to by an alias:</p><div class="codesample clear"><table><tr><td scope="row"><pre>POSIX path of zApp --result: "/System/Library/CoreServices/Finder.app/"<span></span></pre></td></tr></table></div><div class="api discussion"><h5>Discussion</h5><p>You can only create an alias to a file or folder that already exists.</p></div> <div class="api specialConsiderations"><h5>Special Considerations</h5><p>AppleScript 2.0 attempts to resolve aliases only when you run a script. However, in earlier versions, AppleScript attempts to resolve aliases at compile time.</p></div><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW2" title="application"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_533"></a><div class="content_ref_head_code">application</div><p>An application on a local machine or an available server.</p><p>An application object in a script has all of the properties described here, which are handled by AppleScript. It may have additional properties, depending on the specific application it refers to.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW9" title="Properties of application objects"></a><h5>Properties of application objects</h5><table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_534"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value is always <code>application</code>.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_535"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>frontmost</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIBBGG" data-renderer-version="1">boolean</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Is the application frontmost?</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Starting in AppleScript 2.0, accessing an application’s <code>frontmost</code> property returns a Boolean value without launching the application or sending it an event.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The value of <code>frontmost</code> for background-only applications, UI element applications such as System Events, and applications that are not running is always <code>false</code>.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_536"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>id</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The application’s bundle identifier (the default) or its four-character signature code. (New in AppleScript 2.0.)</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">For example, the bundle identifier for the TextEdit application is <code>"com.apple.TextEdit"</code>. Its four-character signature code is <code>'ttxt'</code>. If you ask for an application object’s <code>id</code> property, you will get the bundle identifier version, unless the application does not have a bundle identifier and does have a signature code.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_537"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>name</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The application’s name.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Starting in AppleScript 2.0, accessing an application’s <code>name</code> property returns the application name as text without launching the application or sending it an event.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_538"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>running</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIBBGG" data-renderer-version="1">boolean</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Is the application running? (New in AppleScript 2.0.)</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Accessing an application’s <code>running</code> property returns a Boolean value without launching the application or sending it an event.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">You can also ask the System Events utility application whether an application is running. While it requires more lines in your script to do so, that option is available in earlier versions of the Mac OS.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_539"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>version</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The application’s version.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Starting in AppleScript 2.0, accessing this property returns the application version as text without launching the application or sending it an event.</td></tr></table><br/><br/><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_18" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>AppleScript supports coercion of an <code>application</code> object to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_19" title="Examples"></a><h5>Examples</h5><p>You can determine whether an application on the current computer is running without launching it (this won’t work if your target is on a remote computer):</p><div class="codesample clear"><table><tr><td scope="row"><pre>tell application "iTunes" -- doesn't automatically launch app<span></span></pre></td></tr><tr><td scope="row"><pre> if it is running then<span></span></pre></td></tr><tr><td scope="row"><pre> pause<span></span></pre></td></tr><tr><td scope="row"><pre> end if<span></span></pre></td></tr><tr><td scope="row"><pre>end tell<span></span></pre></td></tr></table></div><p>You can also use this format:</p><div class="codesample clear"><table><tr><td scope="row"><pre>if application "iTunes" is running<span></span></pre></td></tr><tr><td scope="row"><pre> tell application "iTunes" to pause<span></span></pre></td></tr><tr><td scope="row"><pre>end if<span></span></pre></td></tr></table></div><p>The following statements specify the TextEdit application by, respectively, its signature, its bundle id, and by a POSIX path to a specific version of TextEdit:</p><div class="codesample clear"><table><tr><td scope="row"><pre>application id "ttxt"<span></span></pre></td></tr><tr><td scope="row"><pre>application id "com.apple.TextEdit"<span></span></pre></td></tr><tr><td scope="row"><pre>application "/Applications/TextEdit.app"<span></span></pre></td></tr></table></div><p>You can target a remote application with a <code>tell</code> statement. For details, see <code><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW9" data-renderer-version="1">Remote Applications</a></code>.</p><div class="api specialConsiderations"><h5>Special Considerations</h5><p>Starting in OS X v10.5, there are several changes in application behavior:</p><ul class="ul"><li class="li"><p>Applications launch hidden.</p><p>AppleScript has always launched applications if it needed to in order to send them a command. However, they would always launch visibly, which could be visually disruptive. AppleScript now launches applications hidden by default. They will not be visible unless the script explicitly says otherwise using <code>activate</code>.</p></li><li class="li"><p>Applications are located lazily.</p><p>When running a script, AppleScript will not attempt to locate an application until it needs to in order to send it a command. This means that a compiled script or script application may contain references to applications that do not exist on the user’s system, but AppleScript will not ask where the missing applications are until it encounters a relevant <code>tell</code> block. Previous versions of AppleScript would attempt to locate every referenced application before running the script.</p><p>When opening a script for editing, AppleScript will attempt to locate all the referenced applications in the entire script, which may mean asking where one is. Pressing the Cancel button only cancels the search for that application; the script will continue opening normally, though custom terminology for that application will display as raw codes. In older versions, pressing Cancel would cancel opening the script.</p></li><li class="li"><p>Applications are located and re-located dynamically.</p><p>Object specifiers that refer to applications, including those in <code>tell</code> blocks, are evaluated every time a script runs. This alleviates problems with scripts getting “stuck” to a particular copy of an application.</p></li></ul><p>In prior versions of AppleScript, use of the new built-in application properties will fall back to sending an event to the application, but the application may not handle these properties in the same way, or handle them at all. (Most applications will handle <code>name</code>, <code>version</code>, and <code>frontmost</code>; <code>id</code> and <code>running</code> are uncommon.) The other new features described above require AppleScript 2.0.</p></div><a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCIBBGG" title="boolean"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_540"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-248070" title="boolean"></a>boolean</div>
<p>A logical truth value.</p><p>A <code>boolean</code> object evaluates to one of the AppleScript constants <code>true</code> or <code>false</code>. A <em class="newTerm">Boolean expression</em> contains one or more <code>boolean</code> objects and evaluates to <code>true</code> or <code>false</code>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-248090" title="Properties of boolean objects"></a><h5>Properties of boolean objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_541"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value is always <code>boolean</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_20" title="Operators"></a><h5>Operators</h5>
<p>The operators that take <code>boolean</code> objects as operands are <code>and</code>, <code>or</code>, <code>not</code>, <code>&</code>, <code>=</code>, and <code>≠</code>, as well as their text equivalents: <code>is equal to</code>, <code>is not equal to</code>, <code>equals</code>, and so on.</p>
<p>The <code>=</code> operator returns <code>true</code> if both operands evaluate to the same value (either <code>true</code> or <code>false</code>); the <code>≠</code> operator returns <code>true</code> if the operands evaluate to different values.</p>
<p>The binary operators <code>and</code> and <code>or</code> take <code>boolean</code> objects as operands and return Boolean values. An <code>and</code> operation, such as <code>(2 > 1) and (4 > 3)</code>, has the value <code>true</code> if both its operands are <code>true</code>, and <code>false</code> otherwise. An <code>or</code> operation, such as <code>(theString = "Yes") or (today = "Tuesday")</code>, has the value <code>true</code> if either of its operands is <code>true</code>.</p><p>The unary <code>not</code> operator changes a <code>true</code> value to <code>false</code> or a <code>false</code> value to <code>true</code>.</p>
<p>The concatenation operator (<code>&</code>) creates a list containing the two boolean values on either side of it; for example:</p><div class="codesample clear"><table><tr><td scope="row"><pre>true & false --result: {true, false}<span></span></pre></td></tr></table></div>
<p>For additional information on these operators, see <span class="content_text"><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-124070" data-renderer-version="1">Operators Reference</a></span>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_21" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of a <code>boolean</code> object to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>, a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object, or an <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_22" title="Examples"></a><h5>Examples</h5><p>The following are simple Boolean expressions:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>true<span></span></pre></td></tr><tr><td scope="row"><pre>false<span></span></pre></td></tr><tr><td scope="row"><pre>paragraphCount > 2<span></span></pre></td></tr></table></div><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_542"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_543"></a>AppleScript supplies the Boolean constants <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_544"></a><code>true</code> and <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_545"></a><code>false</code> to serve as the result of evaluating a Boolean operation. But scripts rarely need to use these literals explicitly because a Boolean expression itself evaluates to a Boolean value. For example, consider the following two script snippets:</p><div class="codesample clear"><table><tr><td scope="row"><pre>if companyName is equal to "Acme Baking" then<span></span></pre></td></tr><tr><td scope="row"><pre> return true<span></span></pre></td></tr><tr><td scope="row"><pre>else<span></span></pre></td></tr><tr><td scope="row"><pre> return false<span></span></pre></td></tr><tr><td scope="row"><pre>end if<span></span></pre></td></tr><tr><td scope="row"><pre> <span></span></pre></td></tr><tr><td scope="row"><pre>return companyName is equal to "Acme Baking"<span></span></pre></td></tr></table></div><p>The second, simpler version, just returns the value of the Boolean comparison <code>companyName is equal to "Acme Baking"</code>, so it doesn’t need to use a Boolean constant.</p><div class="api discussion"><h5>Discussion</h5><p>When you pass a Boolean value as a parameter to a command, the form may change when you compile the command. For example, the following line</p><div class="codesample clear"><table><tr><td scope="row"><pre>choose folder showing package contents true<span></span></pre></td></tr></table></div><p>is converted to this when compiled by AppleScript:</p><div class="codesample clear"><table><tr><td scope="row"><pre>choose folder with showing package contents<span></span></pre></td></tr></table></div><p>It is standard for AppleScript to compile parameter expressions from the Boolean form (such as <code>showing package contents true</code> or <code>invisibles false</code>) into the <code>with</code> form (<code>with showing package contents</code> or <code>without invisibles</code>, respectively).</p></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" title="class"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_546"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-248396" title="class"></a>class</div>
<p>Specifies the class of an object or value.</p>
<p>All classes have a <code>class</code> property that specifies the class type. The value of the <code>class</code> property is an identifier.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-248431" title="Properties of class objects"></a><h5>Properties of class objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_547"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>class</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_23" title="Operators"></a><h5>Operators</h5>
<p>The operators that take class identifier values as operands are <code>&</code>, <code>=</code>, <code>≠</code>, and <code>as</code>.</p>
<p>The coercion operator <code>as</code> takes an object of one class type and coerces it to an object of a type specified by a class identifier. For example, the following statement coerces a <code>text</code> object into a corresponding <code>real</code>:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>"1.5" as real --result: 1.5<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_24" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of a class identifier to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code> or a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_25" title="Examples"></a><h5>Examples</h5><p>Asking for the class of a type such as <code>integer</code> results in a value of <code>class</code>:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>class of text --result: class<span></span></pre></td></tr><tr><td scope="row"><pre>class of integer --result: class<span></span></pre></td></tr></table></div><p>Here is the class of a boolean literal:</p><div class="codesample clear"><table><tr><td scope="row"><pre>class of true --result: boolean<span></span></pre></td></tr></table></div><p>And here are some additional examples:</p><div class="codesample clear"><table><tr><td scope="row"><pre>class of "Some text" --result: text<span></span></pre></td></tr><tr><td scope="row"><pre>class of {1, 2, "hello"} --result: list<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCECDHC" title="constant"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_548"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-248637" title="constant"></a>constant</div>
<p>A word with a predefined value.</p><p>Constants are generally used for enumerated types. You cannot define constants in scripts; constants can be defined only by applications and by AppleScript. See <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-BAJBDEJI" data-renderer-version="1">Global Constants in AppleScript</a></span> for more information.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-248702" title="Properties of constant objects"></a><h5>Properties of constant objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_549"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>constant</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_26" title="Operators"></a><h5>Operators</h5>
<p>The operators that take <code>constant</code> objects as operands are <code>&</code>, <code>=</code>, <code>≠</code>, and <code>as</code>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_27" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of a <code>constant</code> object to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code> or a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_28" title="Examples"></a><h5>Examples</h5><p>One place you use constants defined by AppleScript is in text comparisons performed with <code>considering</code> or <code>ignoring</code> statements (described in <code><a href="ASLR_control_statements.html#//apple_ref/doc/uid/TP40000983-CH6g-159879" data-renderer-version="1">considering / ignoring (text comparison)</a></code>). For example, in the following script statements, <code>punctuation</code>, <code>hyphens</code>, and <code>white space</code> are constants:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>considering punctuation but ignoring hyphens and white space<span></span></pre></td></tr><tr><td scope="row"><pre> "bet-the farm," = "BetTheFarm," --result: true<span></span></pre></td></tr><tr><td scope="row"><pre>end considering<span></span></pre></td></tr><tr><td scope="row"><pre>class of hyphens --result: constant<span></span></pre></td></tr></table></div><p>The final statement shows that the class of <code>hyphens</code> is <code>constant</code>.</p>
<div class="api discussion"><h5>Discussion</h5><p>Constants are not text strings, and they must not be surrounded by quotation marks.</p><p>Literal constants are defined in <span class="content_text"><a href="../conceptual/ASLR_lexical_conventions.html#//apple_ref/doc/uid/TP40000983-CH214-SW10" data-renderer-version="1">Literals and Constants</a></span>.</p><p>In addition to the constants defined by AppleScript, applications often define enumerated types to be used for command parameters or property values. For example, the iTunes <code>search</code> command defines these constants for specifying the search area:</p><div class="codesample clear"><table><tr><td scope="row"><pre>albums<span></span></pre></td></tr><tr><td scope="row"><pre>all<span></span></pre></td></tr><tr><td scope="row"><pre>artists<span></span></pre></td></tr><tr><td scope="row"><pre>composers<span></span></pre></td></tr><tr><td scope="row"><pre>displayed<span></span></pre></td></tr><tr><td scope="row"><pre>songs<span></span></pre></td></tr></table></div></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCGECID" title="date"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_550"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-249049" title="date"></a>date</div>
<p>Specifies the day of the week, the date (month, day of the month, and year), and the time (hours, minutes, and seconds).</p><p>To get the current date, use the command <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW39" data-renderer-version="1">current date</a></code>:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set theDate to current date<span></span></pre></td></tr><tr><td scope="row"><pre>--result: "Friday, November 9, 2007 11:35:50 AM"<span></span></pre></td></tr></table></div>
<p>You can get and set the different parts of a <code>date</code> object through the date and time properties described below.</p>
<p>When you compile a script, AppleScript displays date and time values according to the format specified in System Preferences.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-249110" title="Properties of date objects"></a><h5>Properties of date objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_551"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>date</code>.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_552"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>day</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read/write</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Specifies the day of the month of a <code>date</code> object.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_553"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>weekday</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCECDHC" data-renderer-version="1">constant</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_554"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_555"></a>Specifies the day of the week of a <code>date</code> object, with one of these constants: <code>Monday</code>, <code>Tuesday</code>, <code>Wednesday</code>, <code>Thursday</code>, <code>Friday</code>, <code>Saturday</code>, or <code>Sunday</code>.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_556"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>month</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read/write</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCECDHC" data-renderer-version="1">constant</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_557"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_558"></a>Specifies the month of the year of a <code>date</code> object, with one of the constants <code>January</code>, <code>February</code>, <code>March</code>, <code>April</code>, <code>May</code>, <code>June</code>, <code>July</code>, <code>August</code>, <code>September</code>, <code>October</code>, <code>November</code>, or <code>December</code>.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_559"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>year</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read/write</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Specifies the year of a <code>date</code> object; for example, <code>2004</code>.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_560"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>time</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read/write</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Specifies the number of seconds since midnight of a <code>date</code> object; for example, <code>2700</code> is equivalent to 12:45 AM (2700 / 60 seconds = 45 minutes).</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_561"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>date string</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">A <code>text</code> object that specifies the date portion of a <code>date</code> object; for example, <code>"Friday, November 9, 2007"</code>.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">To obtain a compact version of the date, use <code>short date string</code> . For example, <code>short date string of (current date) --result: "1/27/08"</code>.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_562"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>time string</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">A <code>text</code> object that specifies the time portion of a <code>date</code> object; for example, <code>"3:20:24 PM"</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_29" title="Operators"></a><h5>Operators</h5>
<p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_563"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_564"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_565"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_566"></a>The operators that take <code>date</code> object as operands are <code>&</code>, <code>+</code>, <code>–</code>, <code>=</code>, <code>≠</code>, <code>></code>, <code>≥</code>, <code><</code>, <code>≤</code>, <code>comes before</code>, <code>comes after</code>, and <code>as</code>. In expressions containing <code>></code>, <code>≥</code>, <code><</code>, <code>≤</code>, <code>comes before</code>, or <code>comes after</code>, a later time is greater than an earlier time.</p><p>AppleScript supports the following operations on <code>date</code> objects with the <code>+</code> and <code>–</code> operators:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>date + timeDifference<span></span></pre></td></tr><tr><td scope="row"><pre>--result: date<span></span></pre></td></tr><tr><td scope="row"><pre>date - date<span></span></pre></td></tr><tr><td scope="row"><pre>--result: timeDifference<span></span></pre></td></tr><tr><td scope="row"><pre>date - timeDifference<span></span></pre></td></tr><tr><td scope="row"><pre>--result: date<span></span></pre></td></tr></table></div>
<p>where <code>timeDifference</code> is an <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code> value specifying a time difference in seconds. To simplify the notation of time differences, you can also use one or more of these of these constants:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>minutes<span></span></pre></td></tr><tr><td scope="row"><pre> 60<span></span></pre></td></tr><tr><td scope="row"><pre>hours<span></span></pre></td></tr><tr><td scope="row"><pre> 60 * minutes<span></span></pre></td></tr><tr><td scope="row"><pre>days<span></span></pre></td></tr><tr><td scope="row"><pre> 24 * hours<span></span></pre></td></tr><tr><td scope="row"><pre>weeks<span></span></pre></td></tr><tr><td scope="row"><pre> 7 * days<span></span></pre></td></tr></table></div>
<p>Here’s an example:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>date "Friday, November 9, 2007" + 4 * days + 3 * hours + 2 * minutes<span></span></pre></td></tr><tr><td scope="row"><pre>--result: date "Tuesday, November 13, 2007 3:02:00 AM"<span></span></pre></td></tr></table></div><p>To express a time difference in more convenient form, divide the number of seconds by the appropriate constant:</p><div class="codesample clear"><table><tr><td scope="row"><pre>31449600 / weeks --result: 52.0<span></span></pre></td></tr></table></div><p>To get an integral number of hours, days, and so on, use the <code>div</code> operator:</p><div class="codesample clear"><table><tr><td scope="row"><pre>151200 div days --result: 1<span></span></pre></td></tr></table></div><p>To get the difference, in seconds, between the current time and Greenwich mean time, use the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW47" data-renderer-version="1">time to GMT</a></code> command.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_30" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of a <code>date</code> object to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code> or a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_31" title="Examples"></a><h5>Examples</h5>
<p>The following expressions show some options for specifying a date, along with the results of compiling the statements. If you construct a date using only partial information, AppleScript fills in the missing pieces with default values. The actual format is based on the settings in System Preferences.</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>date "8/9/2007, 17:06"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Thursday, August 9, 2007 5:06:00 PM"<span></span></pre></td></tr><tr><td scope="row"><pre>date "7/16/70"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Wednesday, July 16, 2070 12:00:00 AM"<span></span></pre></td></tr><tr><td scope="row"><pre>date "12:06" -- specifies a time on the current date<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Friday, November 9, 2007 12:06:00 PM"<span></span></pre></td></tr><tr><td scope="row"><pre>date "Sunday, December 12, 1954 12:06 pm"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Sunday, December 12, 1954 12:06:00 PM"<span></span></pre></td></tr></table></div><p>The following statements access various date properties (results depend on the date the statements are executed):</p><div class="codesample clear"><table><tr><td scope="row"><pre>set theDate to current date --using current date command<span></span></pre></td></tr><tr><td scope="row"><pre>--result: date "Friday, November 9, 2007 11:58:38 AM"<span></span></pre></td></tr><tr><td scope="row"><pre>weekday of theDate --result: Friday<span></span></pre></td></tr><tr><td scope="row"><pre>day of theDate --result: 9<span></span></pre></td></tr><tr><td scope="row"><pre>month of theDate --result: November<span></span></pre></td></tr><tr><td scope="row"><pre>year of theDate --result: 2007<span></span></pre></td></tr><tr><td scope="row"><pre>time of theDate --result: 43118 (seconds since 12:00:00 AM)<span></span></pre></td></tr><tr><td scope="row"><pre>time string of theDate --result: "11:58:38 AM"<span></span></pre></td></tr><tr><td scope="row"><pre>date string of theDate --result: "Friday, November 9, 2007"<span></span></pre></td></tr></table></div><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_567"></a>If you want to specify a time relative to a date, you can do so by using <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_568"></a><code>of</code>, <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_569"></a><code>relative to</code>, or <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_570"></a><code>in</code>, as shown in the following examples.</p><div class="codesample clear"><table><tr><td scope="row"><pre>date "2:30 am" of date "Jan 1, 2008"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Tuesday, January 1, 2008 2:30:00 AM"<span></span></pre></td></tr><tr><td scope="row"><pre>date "2:30 am" of date "Sun Jan 27, 2008"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Sunday, January 27, 2008 2:30:00 AM"<span></span></pre></td></tr><tr><td scope="row"><pre>date "Nov 19, 2007" relative to date "3PM"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Monday, November 19, 2007 3:00:00 PM"<span></span></pre></td></tr><tr><td scope="row"><pre>date "1:30 pm" in date "April 1, 2008"<span></span></pre></td></tr><tr><td scope="row"><pre> --result: date "Tuesday, April 1, 2008 1:30:00 PM"<span></span></pre></td></tr></table></div><div class="api specialConsiderations"><h5>Special Considerations</h5><p>You can create a <code>date</code> object using a string that follows the date format specified in the Formats pane in International preferences. For example, in US English:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set myDate to date "3/4/2008"<span></span></pre></td></tr></table></div><p>When you compile this statement, it is converted to the following:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set myDate to date "Tuesday, March 4, 2008 12:00:00 AM"<span></span></pre></td></tr></table></div></div><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW17" title="file"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_571"></a><div class="content_ref_head_code">file</div><p>A reference to a file, folder, or volume in the file system. A <code>file</code> object has exactly the same attributes as an <code>alias</code> object, with the addition that it can refer to an item that does not exist.</p><p>For related information, see <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW3" data-renderer-version="1">alias</a></code> and <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW15" data-renderer-version="1">POSIX file</a></code>. For a description of the format for a file path, see <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW28" data-renderer-version="1">Aliases and Files</a></span>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_32" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>AppleScript supports coercion of a <code>file</code> object to a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object or single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_33" title="Examples"></a><h5>Examples</h5><div class="codesample clear"><table><tr><td scope="row"><pre>set fp to open for access file "Leopard:Users:myUser:NewFile"<span></span></pre></td></tr><tr><td scope="row"><pre>close access fp<span></span></pre></td></tr></table></div><div class="api discussion"><h5>Discussion</h5><p>You can create a <code>file</code> object that refers to a file or folder that does not exist. For example, you can use the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW5" data-renderer-version="1">choose file name</a></code> command to obtain a <code>file</code> object for a file that need not currently exist.</p></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" title="integer"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_572"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-250260" title="integer"></a>integer</div>
<p>A number without a fractional part.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-250284" title="Properties of integer objects"></a><h5>Properties of integer objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_573"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>integer</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_34" title="Operators"></a><h5>Operators</h5><p>The operators that can have <code>integer</code> values as operands are <code>+</code>, <code>-</code>, <code>*</code>, <code>÷</code> (or <code>/</code>), <code>div</code>, <code>mod</code>, <code>^</code>, <code>=</code>, <code>≠</code>, <code>></code>, <code>≥</code>, <code><</code>, and <code>≤</code>.</p>
<p>The <code>div</code> operator always returns an <code>integer</code> value as its result. The <code>+</code>, <code>–</code>, <code>*</code>, <code>mod</code>, and <code>^</code> operators return values of type <code>integer</code> or <code>real</code>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_35" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of an <code>integer</code> value to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>, a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCJECEC" data-renderer-version="1">real</a></code> number, or a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object.</p>
<p>Coercion of an <code>integer</code> to a <code>number</code> does nothing:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>set myCount to 7 as number<span></span></pre></td></tr><tr><td scope="row"><pre>class of myCount --result: integer<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_36" title="Examples"></a><h5>Examples</h5>
<div class="codesample clear"><table><tr><td scope="row"><pre>1<span></span></pre></td></tr><tr><td scope="row"><pre>set myResult to 3 - 2<span></span></pre></td></tr><tr><td scope="row"><pre>-1<span></span></pre></td></tr><tr><td scope="row"><pre>1000<span></span></pre></td></tr></table></div>
<div class="api discussion"><h5>Discussion</h5>
<p>The biggest value (positive or negative) that can be expressed as an integer in AppleScript is ±536870911, which is equal to ±(2^29 – 1). Larger integers are converted to real numbers, expressed in exponential notation, when scripts are compiled.</p><div class="notebox"><aside><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW10" title="Note"></a><p><strong>Note:</strong> The smallest possible <code>integer</code> value is actually -536870912 (-2^29), but it can only be generated as a result of an expression. If you enter it directly into a script, it will be converted to a real when you compile.</p><p></p></aside></div></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" title="list"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_574"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-250569" title="list"></a>list</div>
<p>An ordered collection of values. The values contained in a list are known as items. Each item can belong to any class.<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_575"></a></p><p>A list appears in a script as a series of expressions contained within braces and separated by commas. An empty list is a list containing no items. It is represented by a pair of empty braces: <code>{}</code><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_576"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_577"></a>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-250594" title="Properties of list objects"></a><h5>Properties of list objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_578"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>list</code>.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_579"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>length</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Specifies he number of items in the list.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_580"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>rest</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">A list containing all items in the list except the first item. <code></code><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_581"></a></td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_582"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>reverse</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">A list containing all items in the list, but in the opposite order.<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_583"></a></td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-250807" title="Elements of list objects"></a><h5>Elements of list objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_584"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>item</code></td></tr>
<tr><td height="7" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_3"></a><p>A value contained in the list. Each value contained in a list is an item and an item may itself be another list. You can refer to values by their item numbers. For example, <code>item 2 of {"soup", 2, "nuts"}</code> is the integer <code>2</code>.</p><p>You can also refer to indexed list items by class. For example, <code>integer 1 of {"oatmeal", 42, "new"}</code> returns <code>42</code>.</p></td></tr></table><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_37" title="Operators"></a><h5>Operators</h5>
<p>The operators that can have list values as operands are <code>&</code>, <code>=</code>, <code>≠</code>, <code>starts with</code>, <code>ends with</code>, <code>contains</code>, and <code>is contained by</code>.</p>
<p>For detailed explanations and examples of how AppleScript operators treat lists, see <span class="content_text"><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-124070" data-renderer-version="1">Operators Reference</a></span>.</p>
<h5>Commands Handled</h5>
<p>You can count the items in a list or the elements of a specific class in a list with the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW55" data-renderer-version="1">count</a></code> command. You can also use the <code>length</code> property of a list:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>count {"a", "b", "c", 1, 2, 3} --result: 6<span></span></pre></td></tr><tr><td scope="row"><pre>length of {"a", "b", "c", 1, 2, 3} --result: 6<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_38" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of a single-item list to any class to which the item can be coerced if it is not part of a list.</p>
<p>AppleScript also supports coercion of an entire list to a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object if each of the items in the list can be coerced to a <code>text</code> object, as in the following example:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>{5, "George", 11.43, "Bill"} as text --result: "5George11.43Bill"<span></span></pre></td></tr></table></div><p>The resulting <code>text</code> object concatenates all the items, separated by the current value of the AppleScript property <code>text item delimiters</code>. This property defaults to an empty string, so the items are simply concatenated. For more information, see <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW22" data-renderer-version="1">text item delimiters</a></span>.</p>
<p>Individual items in a list can be of any class, and AppleScript supports coercion of any value to a list that contains a single item. </p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_39" title="Examples"></a><h5>Examples</h5>
<p>The following statement defines a list that contains a <code>text</code> object, an integer, and a Boolean value:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>{ "it's", 2, true }<span></span></pre></td></tr></table></div>
<p>Each list item can be any valid expression. The following list has the same value as the previous list:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>{ "it" & "'s", 1 + 1, 4 > 3 }<span></span></pre></td></tr></table></div><p>The following statements work with lists; note that the concatenation operator (<code>&</code>) joins two lists into a single list:<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_585"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_586"></a></p><div class="codesample clear"><table><tr><td scope="row"><pre>class of {"this", "is", "a", "list"} --result: list<span></span></pre></td></tr><tr><td scope="row"><pre>item 3 of {"this", "is", "a", "list"} --result: "a"<span></span></pre></td></tr><tr><td scope="row"><pre>items 2 thru 3 of {"soup", 2, "nuts"} --result: {2, "nuts"}<span></span></pre></td></tr><tr><td scope="row"><pre>{"This"} & {"is", "a", "list"} --result: {"This", "is", "a", "list"}<span></span></pre></td></tr></table></div><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_587"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_588"></a>For large lists, it is more efficient to use the <code>a reference to operator</code> when inserting a large number of items into a list, rather than to access the list directly. For example, using direct access, the following script takes about 10 seconds to create a list of 10,000 integers (results will vary depending on the computer and other factors):</p><div class="codesample clear"><table><tr><td scope="row"><pre>set bigList to {}<span></span></pre></td></tr><tr><td scope="row"><pre>set numItems to 10000<span></span></pre></td></tr><tr><td scope="row"><pre>set t to (time of (current date)) --Start timing operations<span></span></pre></td></tr><tr><td scope="row"><pre>repeat with n from 1 to numItems<span></span></pre></td></tr><tr><td scope="row"><pre> copy n to the end of bigList<span></span></pre></td></tr><tr><td scope="row"><pre> -- DON'T DO THE FOLLOWING--it's even slower!<span></span></pre></td></tr><tr><td scope="row"><pre> -- set bigList to bigList & n<span></span></pre></td></tr><tr><td scope="row"><pre>end<span></span></pre></td></tr><tr><td scope="row"><pre>set total to (time of (current date)) - t --End timing<span></span></pre></td></tr></table></div><p>But the following script, which uses the <code>a reference to operator</code>, creates a list of 100,000 integers (ten times the size) in just a couple of seconds (again, results may vary):</p><div class="codesample clear"><table><tr><td scope="row"><pre>set bigList to {}<span></span></pre></td></tr><tr><td scope="row"><pre>set bigListRef to a reference to bigList<span></span></pre></td></tr><tr><td scope="row"><pre>set numItems to 100000<span></span></pre></td></tr><tr><td scope="row"><pre>set t to (time of (current date)) --Start timing operations<span></span></pre></td></tr><tr><td scope="row"><pre>repeat with n from 1 to numItems<span></span></pre></td></tr><tr><td scope="row"><pre> copy n to the end of bigListRef<span></span></pre></td></tr><tr><td scope="row"><pre>end<span></span></pre></td></tr><tr><td scope="row"><pre>set total to (time of (current date)) - t --End timing<span></span></pre></td></tr></table></div><p>Similarly, accessing the items in the previously created list is much faster using <code>a reference to</code>—the following takes just a few seconds:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set t to (time of (current date)) --Start timing<span></span></pre></td></tr><tr><td scope="row"><pre>repeat with n from 1 to numItems -- where numItems = 100,000<span></span></pre></td></tr><tr><td scope="row"><pre> item n of bigListRef<span></span></pre></td></tr><tr><td scope="row"><pre>end repeat<span></span></pre></td></tr><tr><td scope="row"><pre>set total to (time of (current date)) - t --End timing<span></span></pre></td></tr></table></div><p>However, accessing the list directly, even for only 4,000 items, can take over a minute:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set numItems to 4000<span></span></pre></td></tr><tr><td scope="row"><pre>set t to (time of (current date)) --Start timing<span></span></pre></td></tr><tr><td scope="row"><pre>repeat with n from 1 to numItems<span></span></pre></td></tr><tr><td scope="row"><pre> item n of bigList<span></span></pre></td></tr><tr><td scope="row"><pre>end repeat<span></span></pre></td></tr><tr><td scope="row"><pre>set total to (time of (current date)) - t --End timing<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCBJDGC" title="number"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_589"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-251399" title="number"></a>number</div>
<p>An abstract class that can represent an <code>integer</code> or a <code>real</code>.</p><p>There is never an object whose class is <code>number</code>; the actual class of a "number" object is always one of the more specific types, <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code> or <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCJECEC" data-renderer-version="1">real</a></code>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-251439" title="Properties of number objects"></a><h5>Properties of number objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_590"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always either <code>integer</code> or <code>real</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_40" title="Operators"></a><h5>Operators</h5>
<p>Because values identified as values of class <code>number</code> are really values of either class <code>integer</code> or class <code>real</code>, the operators available are the operators described in the definitions of the <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code> or <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCJECEC" data-renderer-version="1">real</a></code> classes.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_41" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>Coercing an object to <code>number</code> results in an <code>integer</code> object if the result of the coercion is an <code>integer</code>, or a <code>real</code> object if the result is a non-integer number.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_42" title="Examples"></a><h5>Examples</h5><p>Any valid literal expression for an <code>integer</code> or a <code>real</code> value is also a valid literal expression for a <code>number</code> value:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>1<span></span></pre></td></tr><tr><td scope="row"><pre>2<span></span></pre></td></tr><tr><td scope="row"><pre>-1<span></span></pre></td></tr><tr><td scope="row"><pre>1000<span></span></pre></td></tr><tr><td scope="row"><pre>10.2579432<span></span></pre></td></tr><tr><td scope="row"><pre>1.0<span></span></pre></td></tr><tr><td scope="row"><pre>1.<span></span></pre></td></tr></table></div><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW15" title="POSIX file"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_591"></a><div class="content_ref_head_code">POSIX file</div><p>A pseudo-class equivalent to the <code>file</code> class.</p><p>There is never an object whose class is <code>POSIX file</code>; the result of evaluating a POSIX file specifier is a <code>file</code> object. The difference between <code>file</code> and <code>POSIX file</code> objects is in how they interpret name specifiers: a <code>POSIX file</code> object interprets <code>"name"</code> as a POSIX path, while a <code>file</code> object interprets it as an HFS path.</p><p>For related information, see <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW3" data-renderer-version="1">alias</a></code> and <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW17" data-renderer-version="1">file</a></code>. For a description of the format for a POSIX path, see <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW28" data-renderer-version="1">Aliases and Files</a></span>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW16" title="Properties of POSIX file objects"></a><h5>Properties of POSIX file objects</h5><p>See <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW17" data-renderer-version="1">file</a></code>.</p><br/><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_43" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>See <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-SW17" data-renderer-version="1">file</a></code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_44" title="Examples"></a><h5>Examples</h5><p>The following example asks the user to specify a file name, starting in the temporary directory <code>/tmp</code>, which is difficult to specify using a file specifier:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set fileName to choose file name default location (POSIX file "/tmp")<span></span></pre></td></tr><tr><td scope="row"><pre> -result: dialog starts in /tmp folder<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCJECEC" title="real"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_592"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-251651" title="real"></a>real</div>
<p>Numbers that can include a fractional part, such as 3.14159 and 1.0.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-251675" title="Properties of real objects"></a><h5>Properties of real objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_593"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>real</code>.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_45" title="Operators"></a><h5>Operators</h5><p>The operators that can have <code>real</code> values as operands are <code>+</code>, <code>-</code>, <code>*</code>, <code>÷</code> (or <code>/</code>), <code>div</code>, <code>mod</code>, <code>^</code>, <code>=</code>, <code>≠</code>, <code>></code>, <code>≥</code>, <code><</code>, and <code>≤</code>.</p>
<p>The <code>÷</code> and <code>/</code> operators always return <code>real</code> values as their results. The <code>+</code>, <code>-</code>, <code>*</code>, <code>mod</code>, and <code>^</code> operators return <code>real</code> values if either of their operands is a <code>real</code> value.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_46" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>AppleScript supports coercion of a <code>real</code> value to an <code>integer</code> value, rounding any fractional part.</p>
<p>AppleScript also supports coercion of a <code>real</code> value to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code> or a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code> object. Coercion to text uses the decimal separator specified in Numbers in the Formats pane in International preferences.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_47" title="Examples"></a><h5>Examples</h5>
<div class="codesample clear"><table><tr><td scope="row"><pre>10.2579432<span></span></pre></td></tr><tr><td scope="row"><pre>1.0<span></span></pre></td></tr><tr><td scope="row"><pre>1.<span></span></pre></td></tr></table></div>
<p>As shown in the third example, a decimal point indicates a real number, even if there is no fractional part.</p>
<p>Real numbers can also be written using exponential notation. A letter <code>e</code> is preceded by a real number (without intervening spaces) and followed by an integer exponent (also without intervening spaces). The exponent can be either positive or negative. To obtain the value, the <code>real</code> number is multiplied by 10 to the power indicated by the exponent, as in these examples:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>1.0e5 --equivalent to 1.0 * 10^5, or 100000<span></span></pre></td></tr><tr><td scope="row"><pre>1.0e+5 --same as 1.0e5<span></span></pre></td></tr><tr><td scope="row"><pre>1.0e-5 --equivalent to 1.0 * 10^-5, or .00001<span></span></pre></td></tr></table></div>
<div class="api discussion"><h5>Discussion</h5>
<p>Real numbers that are greater than or equal to 10,000.0 or less than or equal to 0.0001 are converted to exponential notation when scripts are compiled. The largest value that can be evaluated (positive or negative) is 1.797693e+308.</p></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCDGEAH" title="record"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_594"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-251978" title="record"></a>record</div>
<p>An unordered collection of labeled properties. The only AppleScript classes that support user-defined properties are <code>record</code> and <code>script</code>.</p><p>A record appears in a script as a series of property definitions contained within braces and separated by commas. Each property definition consists of a label, a colon, and the value of the property. For example, this is a record with two properties: <code>{product:"pen", price:2.34}</code>.</p><p>Each property in a record has a unique label which distinguishes it from other properties in the collection. The values assigned to properties can belong to any class. You can change the class of a property simply by assigning a value belonging to another class.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-252002" title="Properties of record objects"></a><h5>Properties of record objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_595"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read/write</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the record. By default, the value is <code>record</code>.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">If you define a <code>class</code> property explicitly in a record, the value you define replaces the implicit <code>class</code> value. In the following example, the class is set to <code>integer</code>:</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><code>set myRecord to {class:integer, min:1, max:10}</code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><code>class of myRecord --result: integer</code></td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_596"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>length</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">Specifies the number of properties in the record.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_48" title="Operators"></a><h5>Operators</h5>
<p>The operators that can have records as operands are <code>&</code>, <code>=</code>, <code>≠</code>, <code>contains</code>, and <code>is contained by</code>.</p>
<p>For detailed explanations and examples of how AppleScript operators treat records, see <span class="content_text"><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-124070" data-renderer-version="1">Operators Reference</a></span>.</p>
<h5>Commands Handled</h5>
<p>You can count the properties in a record with the <code>count</code> command:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>count {name:"Robin", mileage:400} --result: 2<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_49" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>AppleScript supports coercion of records to lists; however, all labels are lost in the coercion and the resulting list cannot be coerced back to a record.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_50" title="Examples"></a><h5>Examples</h5>
<p>The following example shows how to change the value of a property in a record:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set myRecord to {product:"pen", price:2.34}<span></span></pre></td></tr><tr><td scope="row"><pre>product of myRecord -- result: "pen"<span></span></pre></td></tr><tr><td scope="row"><pre> <span></span></pre></td></tr><tr><td scope="row"><pre>set product of myRecord to "pencil"<span></span></pre></td></tr><tr><td scope="row"><pre>product of myRecord -- result: "pencil"<span></span></pre></td></tr></table></div><p>AppleScript evaluates expressions in a record before using the record in other expressions. For example, the following two records are equivalent:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>{ name:"Steve", height:76 - 1.5, weight:150 + 20 }<span></span></pre></td></tr><tr><td scope="row"><pre>{ name:"Steve", height:74.5, weight:170 }<span></span></pre></td></tr></table></div><p>You cannot refer to properties in records by numeric index. For example, the following object specifier, which uses the index reference form on a record, is not valid.</p><div class="codesample clear"><table><tr><td scope="row"><pre>item 2 of { name:"Rollie", IQ:186, city:"Unknown" } --result: error<span></span></pre></td></tr></table></div><p>You can access the <em>length</em> property of a record to count the properties it contains:</p><div class="codesample clear"><table><tr><td scope="row"><pre>length of {name:"Chris", mileage:1957, city:"Kalamazoo"} --result: 3<span></span></pre></td></tr></table></div><p>You can get the same value with the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW55" data-renderer-version="1">count</a></code> command:</p><div class="codesample clear"><table><tr><td scope="row"><pre>count {name:"Chris", mileage:1957, city:"Kalamazoo"} --result: 3<span></span></pre></td></tr></table></div>
<div class="api discussion"><h5>Discussion</h5>
<p>After you define a record, you cannot add additional properties to it. You can, however, concatenate records. For more information, see <code><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-BAJEGEEC" data-renderer-version="1">& (concatenation)</a></code>.</p></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCDJJDE" title="reference"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_597"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-252489" title="reference"></a>reference</div>
<p>An object that encapsulates an object specifier.</p><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_598"></a>The result of the <code><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-SW1" data-renderer-version="1">a reference to</a></code> operator is a <code>reference</code> object, and object specifiers returned from application commands are implicitly turned into <code>reference</code> objects.</p><p>A <code>reference</code> object “wraps” an object specifier. If you target a <code>reference</code> object with the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW56" data-renderer-version="1">get</a></code> command, the command returns the <code>reference</code> object itself. If you ask a <code>reference</code> object for its <code>contents</code> property, it returns the enclosed object specifier. All other requests to a <code>reference</code> object are forwarded to its enclosed object specifier. For example, if you ask for the <code>class</code> of a <code>reference</code> object, you get the <code>class</code> of the object specified by its object specifier.</p><p>For related information, see <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW7" data-renderer-version="1">Object Specifiers</a></span>.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-252730" title="Properties of reference objects"></a><h5>Properties of reference objects</h5><p>Other than the <code>contents</code> property, all other property requests are forwarded to the enclosed object specifier, so the reference object appears to have all the properties of the referenced object.</p>
<table border="0" cellpadding="0" cellspacing="1" width="100%">
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_599"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>contents</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> depends on the referenced object or objects</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3">depends on the referenced object or objects</td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The enclosed object specifier.<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_600"></a></td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_51" title="Operators"></a><h5>Operators</h5>
<p>All operators are forwarded to the enclosed object specifier, so the reference object appears to support all the operators of referenced object.</p><p>The <code>a reference to</code> operator returns a reference object as its result.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_52" title="Coercions Supported"></a><h5>Coercions Supported</h5>
<p>All coercions are forwarded to the enclosed object specifier, so the reference object appears to support all the coercions of referenced object.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_53" title="Examples"></a><h5>Examples</h5><p>Reference objects are most often used to specify application objects. The following example creates a reference to a window within the TextEdit application:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set myWindow to a ref to window "top.rtf" of application "TextEdit"<span></span></pre></td></tr><tr><td scope="row"><pre>--result: window "top.rtf" of application "TextEdit"<span></span></pre></td></tr></table></div><p>In subsequent script statements, you can use the variable <code>myWindow</code> in place of the longer term <code>window "top.rtf" of application "TextEdit"</code>.</p><p>Because all property requests other than <code>contents of</code> are forwarded to its enclosed specifier, the <code>reference</code> object appears to have all the properties of the referenced object. For example, both <code>class of</code> statements in the following example return <code>window</code>:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set myRef to a reference to window 1<span></span></pre></td></tr><tr><td scope="row"><pre>class of contents of myRef -- explicit dereference using "contents of"<span></span></pre></td></tr><tr><td scope="row"><pre>class of myRef -- implicit dereference<span></span></pre></td></tr></table></div><p>For additional examples, see the <code><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-SW1" data-renderer-version="1">a reference to</a></code> operator.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW1" title="RGB color"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_601"></a><div class="content_ref_head_code">RGB color</div><p>A type definition for a three-item list of <code>integer</code> values, from 0 to 65535, that specify the red, green, and blue components of a color.<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_602"></a></p><p>Otherwise, behaves exactly like a <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code> object.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_54" title="Examples"></a><h5>Examples</h5><div class="codesample clear"><table><tr><td scope="row"><pre>set whiteColor to {65535, 65535, 65535} -- white<span></span></pre></td></tr><tr><td scope="row"><pre>set yellowColor to {65535, 65535, 0} -- yellow<span></span></pre></td></tr><tr><td scope="row"><pre>yellowColor as string --result: "65535655350"<span></span></pre></td></tr><tr><td scope="row"><pre>set redColor to {65535, 0, 0} -- red<span></span></pre></td></tr><tr><td scope="row"><pre>set userColor to choose color default color redColor<span></span></pre></td></tr></table></div><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW5" title="script"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_603"></a><div class="content_ref_head_code">script</div><p>A collection of AppleScript declarations and statements that can be executed as a group.</p><p>The syntax for a <code>script</code> object is described in <span class="content_text"><a href="../conceptual/ASLR_script_objects.html#//apple_ref/doc/uid/TP40000983-CH207-SW2" data-renderer-version="1">Defining Script Objects</a></span>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW13" title="Properties of script objects"></a><h5>Properties of script objects</h5><table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_604"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>script</code>.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_605"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>name</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read-only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The name of the script object, implicitly defined in AppleScript 2.3 and later. For top-level scripts, this is the name of the file the script is saved in, unless explicitly defined otherwise using a property, or, for a top-level script saved as a script bundle, using the Info.plist key <code>CFBundleName</code>. Script Editor’s Bundle Contents drawer includes a “Name” field to set this value. For other script objects, it is the name the script was defined with, as text.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_606"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>id</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read-only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The unique identifier of the script object, implicitly defined in AppleScript 2.3 and later. Its value is <code>missing value</code> unless explicitly defined using a property, or, for a top-level script saved as a script bundle, using the Info.plist key <code>CFBundleIdentifier</code>. Script Editor’s Bundle Contents drawer includes an “Identifier” field to set this value.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_607"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>version</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read-only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The version of the script object, implicitly defined in AppleScript 2.3 and later. For top-level scripts, its value is <code>"1.0"</code> unless explicitly defined using a property, or, for a script bundle, using the Info.plist key <code>CFBundleShortVersionString</code>. Script Editor’s Bundle Contents drawer includes a “Short Version” field to set this value. For other script objects, its default value is <code>missing value</code>. While the version may resemble a number, it is actually of type <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code>. For best results, compare version strings using <code>considering numeric strings</code>.</td></tr></table><br/><br/><h5>Commands Handled</h5><p>You can copy a <code>script</code> object with the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW53" data-renderer-version="1">copy</a></code> command or create a reference to it with the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW52" data-renderer-version="1">set</a></code> command.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_55" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>AppleScript supports coercion of a <code>script</code> object to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_56" title="Examples"></a><h5>Examples</h5><p>The following example shows a simple <code>script</code> object that displays a dialog. It is followed by a statement that shows how to run the script:</p><div class="codesample clear"><table><tr><td scope="row"><pre>script helloScript<span></span></pre></td></tr><tr><td scope="row"><pre> display dialog "Hello."<span></span></pre></td></tr><tr><td scope="row"><pre>end script<span></span></pre></td></tr><tr><td scope="row"><pre> <span></span></pre></td></tr><tr><td scope="row"><pre>run helloScript -- invoke the script<span></span></pre></td></tr></table></div><div class="api discussion"><h5>Discussion</h5><p>A <code>script</code> object can contain other <code>script</code> objects, called child scripts, and can have a parent object. For additional information, including more detailed examples, see <span class="content_text"><a href="../conceptual/ASLR_script_objects.html#//apple_ref/doc/uid/TP40000983-CH207-BAJJCIAA" data-renderer-version="1">Script Objects</a></span>.</p><p>The <code>name</code>, <code>id</code>, and <code>version</code> properties are automatically defined in OS X Mavericks v10.9 (AppleScript 2.3) and later, and are used to identify scripts used as libraries, as described in <span class="content_text"><a href="../conceptual/ASLR_script_objects.html#//apple_ref/doc/uid/TP40000983-CH207-BAJJCIAA" data-renderer-version="1">Script Objects</a></span>.</p></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" title="text"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_608"></a><div class="content_ref_head_code"><a name="//apple_ref/doc/uid/TP40000983-CH1g-253053" title="text"></a>text</div><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_609"></a>
<p>An ordered series of Unicode characters.</p><p>Starting in AppleScript 2.0, AppleScript is entirely Unicode-based. There is no longer a distinction between Unicode and non-Unicode text. Comments and text constants in scripts may contain any Unicode characters, and all text processing is done in Unicode, so all characters are preserved correctly regardless of the user’s language preferences.</p><p>For example, the following script works correctly in AppleScript 2.0, where it would not have in previous versions:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set jp to "日本語"<span></span></pre></td></tr><tr><td scope="row"><pre>set ru to "Русский"<span></span></pre></td></tr><tr><td scope="row"><pre>jp & " and " & ru -- returns "日本語 and Русский"<span></span></pre></td></tr></table></div><p>For information on compatibility with previous AppleScript versions, including the use of <code>string</code> and <code>Unicode text</code> as synonyms for <code>text</code>, see the Special Considerations section.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-253086" title="Properties of text objects"></a><h5>Properties of text objects</h5>
<table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_610"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCFEDGB" data-renderer-version="1">class</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. The value of this property is always <code>text</code>.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_611"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>id</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read-only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code> or <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code> of integer</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">A value (or list of values) representing the Unicode code point (or code points) for the character (or characters) in the <code>text</code> object. (A <em class="newTerm">Unicode code point</em> is a unique number that represents a character and allows it to be represented in an abstract way, independent of how it is rendered. A character in a <code>text</code> object may be composed of one or more code points.)</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">This property, added in AppleScript 2.0, can also be used as an address, which allows mapping between Unicode code point values and the characters at those code points. For example, <code>id of "A"</code> returns <code>65</code>, and <code>character id 65</code> returns <code>"A"</code>.</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The id of text longer than one code point is a list of integers, and vice versa: for example, <code>id of "hello"</code> returns <code>{104, 101, 108, 108, 111}</code>, and <code>string id {104, 101, 108, 108, 111}</code> returns <code>"hello"</code>. (Because of a bug, <code>text id ...</code> does not work; you must use one of <code>string</code>, <code>Unicode text</code>, or <code>character</code>.)</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">These uses of the <code>id</code> property obsolete the older <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW21" data-renderer-version="1">ASCII character</a></code> and <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW22" data-renderer-version="1">ASCII number</a></code> commands, since, unlike those, they cover the full Unicode character range and will return the same results regardless of the user's language preferences.</td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_612"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>length</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The number of characters in the text.</td></tr>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_613"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>quoted form</code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3"> read only</td></tr>
<tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3"><code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code></td></tr>
<tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">A representation of the text that is safe from further interpretation by the shell, no matter what its contents are. Mainly useful for passing a text string to the <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW40" data-renderer-version="1">do shell script</a></code> command.</td></tr></table><br/><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-253199" title="Elements of text objects"></a><h5>Elements of text objects</h5><p>A <code>text</code> object can contain these elements (which may behave differently than similar elements used in applications):</p><table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_614"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>character</code></td></tr><tr><td height="7" scope="row"> </td><td valign="top" height="10" width="80" class="content_text">Specify by: </td><td valign="top" height="10" colspan="3"><span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BCIJEEHE" data-renderer-version="1">Arbitrary</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFIIH" data-renderer-version="1">Every</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCGHGAF" data-renderer-version="1">Index</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFDBA" data-renderer-version="1">Middle</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCHDJJJ" data-renderer-version="1">Range</a></span></td></tr><tr><td height="7" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_4"></a><p>One or more Unicode characters that make up the text.<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_615"></a></p><p>Starting in AppleScript 2.0, elements of <code>text</code> object count a combining character cluster (also known as a Unicode grapheme cluster) as a single character. (This relates to a feature of Unicode that is unlikely to have an impact on most scripters: some “characters” may be represented as either a single entity or as a base character plus a series of combining marks.</p><p>For example, “é” may be encoded as either U+00E9 (LATIN SMALL LETTER E WITH ACUTE) or as U+0065 (LATIN SMALL LETTER E), U+0301 (COMBINING ACUTE ACCENT). Nonetheless, AppleScript 2.0 will count both as one character, where older versions counted the base character and combining mark separately.</p></td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_616"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>paragraph</code></td></tr><tr><td height="7" scope="row"> </td><td valign="top" height="10" width="80" class="content_text">Specify by: </td><td valign="top" height="10" colspan="3"><span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BCIJEEHE" data-renderer-version="1">Arbitrary</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFIIH" data-renderer-version="1">Every</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCGHGAF" data-renderer-version="1">Index</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFDBA" data-renderer-version="1">Middle</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCHDJJJ" data-renderer-version="1">Range</a></span></td></tr><tr><td height="7" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_5"></a><p>A series of characters beginning immediately after either the first character after the end of the preceding paragraph or the beginning of the text and ending with either a carriage return character (<code>\r</code>), a linefeed character (<code>\n</code>), a return/linefeed pair (<code>\r\n</code>), or the end of the text. The Unicode "paragraph separator" character (U+2029) is not supported.</p><p>Because <code>paragraph</code> elements are <em>separated</em> by a carriage return, linefeed, or carriage return/linefeed pair, text ending with a paragraph break specifies a following (empty) paragraph. For example, <code>"this\nthat\n"</code> has three paragraphs, not two: "this", "that", and "" (the empty paragraph after the trailing linefeed).</p><p>Similarly, two paragraph breaks in a row specify an empty paragraph between them:</p><p><code>paragraphs of "this\n\nthat" --result: {"this", "", "that"}</code></p></td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_617"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>text</code></td></tr><tr><td height="7" scope="row"> </td><td valign="top" height="10" width="80" class="content_text">Specify by: </td><td valign="top" height="10" colspan="3"><span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFIIH" data-renderer-version="1">Every</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCIBAAJ" data-renderer-version="1">Name</a></span></td></tr><tr><td height="7" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_6"></a><p>All of the text contained in the <code>text</code> object, including spaces, tabs, and all other characters.</p><p>You can use <code>text</code> to access contiguous characters (but see also the Discussion section below):</p><p><code>text 1 thru 5 of "Bring me the mouse." --result: "Bring"</code></p></td></tr><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_618"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>word</code></td></tr><tr><td height="7" scope="row"> </td><td valign="top" height="10" width="80" class="content_text">Specify by: </td><td valign="top" height="10" colspan="3"><span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BCIJEEHE" data-renderer-version="1">Arbitrary</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFIIH" data-renderer-version="1">Every</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCGHGAF" data-renderer-version="1">Index</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCJFDBA" data-renderer-version="1">Middle</a></span>, <span class="content_text"><a href="ASLR_reference_forms.html#//apple_ref/doc/uid/TP40000983-CH4g-BBCHDJJJ" data-renderer-version="1">Range</a></span></td></tr><tr><td height="7" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_7"></a><p>A continuous series of characters, with word elements parsed according to the word-break rules set in the International preference pane.</p><p>Because the rules for parsing words are thus under user control, your scripts should not count on a deterministic text parsing of words.</p></td></tr></table><br/>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_57" title="Operators"></a><h5>Operators</h5>
<p>The operators that can have <code>text</code> objects as operands are <code>&</code>, <code>=</code>, <code>≠</code>, <code>></code>, <code>≥</code>, <code><</code>,<code> ≤</code>, <code>starts with</code>, <code>ends with</code>, <code>contains</code>, <code>is contained by</code>, and <code>as</code>.</p><p>In text comparisons, you can specify whether white space should be considered or ignored. For more information, see <code><a href="ASLR_control_statements.html#//apple_ref/doc/uid/TP40000983-CH6g-130224" data-renderer-version="1">considering and ignoring Statements</a></code>.</p>
<p>For detailed explanations and examples of how AppleScript operators treat <code>text</code> objects, see <span class="content_text"><a href="ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-124070" data-renderer-version="1">Operators Reference</a></span>.</p><h5>Special String Characters</h5><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_619"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_620"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_621"></a>The backslash (<code>\</code>) and double-quote (<code>"</code>) characters have special meaning in text. AppleScript encloses text in double-quote characters and uses the backslash character to represent return (<code>\r</code>), tab (<code>\t</code>), and linefeed (\n) characters (described below). So if you want to include an actual backslash or double-quote character in a <code>text</code> object, you must use the equivalent two-character sequence. As a convenience, AppleScript also provides the text constant <code>quote</code>, which has the value <code>\"</code>. <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_622"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_623"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_624"></a></p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW6" title="Table 6-1Special characters in text"></a><div class="tableholder"><table class="graybox" border = "0" cellspacing="0" cellpadding="5"><caption class="tablecaption"><strong class="caption_number">Table 6-1</strong> Special characters in text</caption><tr><th scope="col" class="TableHeading_TableRow_TableCell"><p>Character</p></th><th scope="col" class="TableHeading_TableRow_TableCell"><p>To insert in text</p></th></tr><tr><td scope="row"><p>Backslash character (<code>\</code>) </p></td><td ><p><code>\\</code></p></td></tr><tr><td scope="row"><p>Double quote (<code>"</code>)</p></td><td ><p><code>\"</code></p><p><code>quote</code> (text constant)</p></td></tr></table></div><p>To declare a <code>text</code> object that looks like this when displayed:</p><div class="codesample clear"><table><tr><td scope="row"><pre>He said "Use the '\' character."<span></span></pre></td></tr></table></div><p>you can use the following:</p><div class="codesample clear"><table><tr><td scope="row"><pre>"He said \"Use the '\\' character.\""<span></span></pre></td></tr></table></div><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_625"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_626"></a>White space refers to text characters that display as vertical or horizontal space. AppleScript defines the white space <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_627"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_628"></a> constants <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_629"></a><code>return</code>, <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_630"></a><code>linefeed</code>, <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_631"></a><code>space</code>, and <a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_632"></a><code>tab</code> to represent, respectively, a return character, a linefeed character, a space character, and a tab character. (The <code>linefeed</code> constant became available in AppleScript 2.0.)</p><p>Although you effectively use these values as text constants, they are actually defined as properties of the global constant <code>AppleScript</code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW7" title="Table 6-2White space constants"></a><div class="tableholder"><table class="graybox" border = "0" cellspacing="0" cellpadding="5"><caption class="tablecaption"><strong class="caption_number">Table 6-2</strong> White space constants</caption><tr><th scope="col" class="TableHeading_TableRow_TableCell"><p>Constant</p></th><th scope="col" class="TableHeading_TableRow_TableCell"><p>Value</p></th></tr><tr><td scope="row"><p>space</p></td><td ><p>" "</p></td></tr><tr><td scope="row"><p>tab</p></td><td ><p>"\t"</p></td></tr><tr><td scope="row"><p>return</p></td><td ><p>"\r"</p></td></tr><tr><td scope="row"><p>linefeed</p></td><td ><p>"\n”</p></td></tr></table></div><p>To enter white space in a string, you can just type the character—that is, you can press the Space bar to insert a space, the Tab key to insert a tab character, or the Return key to insert a return. In the latter case, the string will appear on two lines in the script, like the following:</p><div class="codesample clear"><table><tr><td scope="row"><pre>display dialog "Hello" & "<span></span></pre></td></tr><tr><td scope="row"><pre>" & "Goodbye"<span></span></pre></td></tr></table></div><p>When you run this script, "Hello" appears above “Goodbye” in the dialog.</p><p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_633"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_634"></a>You can also enter a tab, return, or linefeed with the equivalent two-character sequences. When a <code>text</code> object containing any of the two-character sequences is displayed to the user, the sequences are converted. For example, if you use the following <code>text</code> object in a <code><a href="ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW12" data-renderer-version="1">display dialog</a></code> command:</p><div class="codesample clear"><table><tr><td scope="row"><pre>display dialog "item 1\t1\ritem 2\t2"<span></span></pre></td></tr></table></div><p>it is displayed like this (unless you enable “Escape tabs and line breaks in strings” in the Editing tab of the of Script Editor preferences):</p><div class="codesample clear"><table><tr><td scope="row"><pre>item 1 1<span></span></pre></td></tr><tr><td scope="row"><pre>item 2 2<span></span></pre></td></tr></table></div><p>To use the white space constants, you use the concatenation operator to join multiple <code>text</code> objects together, as in the following example:</p><div class="codesample clear"><table><tr><td scope="row"><pre>"Year" & tab & tab & "Units sold" & return & "2006" & tab ¬<span></span></pre></td></tr><tr><td scope="row"><pre> & tab & "300" & return & "2007" & tab & tab & "453"<span></span></pre></td></tr></table></div><p>When passed to <code>display dialog</code>, this text is displayed as follows:</p><div class="codesample clear"><table><tr><td scope="row"><pre>Year Units sold<span></span></pre></td></tr><tr><td scope="row"><pre>2006 300<span></span></pre></td></tr><tr><td scope="row"><pre>2007 453<span></span></pre></td></tr></table></div>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_58" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>AppleScript supports coercion of an <code>text</code> object to a single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>. If a <code>text</code> object represents an appropriate number, AppleScript supports coercion of the <code>text</code> object to an integer or a real number.</p>
<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_59" title="Examples"></a><h5>Examples</h5>
<p>You can define a <code>text</code> object in a script by surrounding text characters with quotation marks, as in these examples:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>set theObject to "some text"<span></span></pre></td></tr><tr><td scope="row"><pre>set clientName to "Mr. Smith"<span></span></pre></td></tr><tr><td scope="row"><pre>display dialog "This is a text object."<span></span></pre></td></tr></table></div><p>Suppose you use the following statement to obtain a <code>text</code> object named <code>docText</code> that contains all the text extracted from a particular document:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set docText to text of document "MyFavoriteFish.rtf" of application "TextEdit"<span></span></pre></td></tr></table></div><p>The following statements show various ways to work with the <code>text</code> object <code>docText</code>:</p><div class="codesample clear"><table><tr><td scope="row"><pre>class of docText --result: text<span></span></pre></td></tr><tr><td scope="row"><pre>first character of docText --result: a character<span></span></pre></td></tr><tr><td scope="row"><pre>every paragraph of docText --result: a list containing all paragraphs<span></span></pre></td></tr><tr><td scope="row"><pre>paragraphs 2 thru 3 of docText --result: a list containing two paragraphs<span></span></pre></td></tr></table></div><p>The next example prepares a <code>text</code> object to use with the <code>display dialog</code> command. It uses the <code>quote</code> constant to insert <code>\"</code> into the text. When this text is displayed in the dialog (above a text entry field), it looks like this: <code>Enter the text in quotes ("text in quotes"): </code></p><div class="codesample clear"><table><tr><td scope="row"><pre>set promptString to "Enter the text in quotes (" & quote ¬<span></span></pre></td></tr><tr><td scope="row"><pre> & "text in quotes" & quote & "): "<span></span></pre></td></tr><tr><td scope="row"><pre>display dialog promptString default answer ""<span></span></pre></td></tr></table></div><p>The following example gets a POSIX path to a chosen folder and uses the <code>quoted form</code> property to ensure correct quoting of the resulting string for use with shell commands:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set folderName to quoted form of POSIX path of (choose folder)<span></span></pre></td></tr></table></div><p>Suppose that you choose the folder named <code>iWork '08</code> in your <code>Applications</code> folder. The previous statement would return the following result, which properly handles the embedded single quote and space characters in the folder name:</p><div class="codesample clear"><table><tr><td scope="row"><pre>"'/Applications/iWork '\\''08/'"<span></span></pre></td></tr></table></div>
<div class="api discussion"><h5>Discussion</h5>
<p>To get a contiguous range of characters within a <code>text</code> object, use the <code>text</code> element. For example, the value of the following statement is the <code>text</code> object <code>"y thi"</code>:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>get text 3 thru 7 of "Try this at home"<span></span></pre></td></tr><tr><td scope="row"><pre>--result: "y thi"<span></span></pre></td></tr></table></div>
<p>The result of a similar statement using the character element instead of the text element is a list:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>get characters 3 thru 7 of "Try this at home"<span></span></pre></td></tr><tr><td scope="row"><pre>--result: {"y", " ", "t", "h", "i"}<span></span></pre></td></tr></table></div>
<p>You cannot set the value of an element of a <code>text</code> object. For example, if you attempt to change the value of the first character of the text object <code>myName</code> as shown next, you’ll get an error:</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>set myName to "Boris"<span></span></pre></td></tr><tr><td scope="row"><pre>set character 1 of myName to "D"<span></span></pre></td></tr><tr><td scope="row"><pre>--result: error: you cannot set the values of elements of text objects<span></span></pre></td></tr></table></div>
<p>However, you can achieve the same result by getting the last four characters and concatenating them with "D":</p>
<div class="codesample clear"><table><tr><td scope="row"><pre>set myName to "boris"<span></span></pre></td></tr><tr><td scope="row"><pre>set myName to "D" & (get text 2 through 5 of myName)<span></span></pre></td></tr><tr><td scope="row"><pre>--result: "Doris"<span></span></pre></td></tr></table></div><p>This example doesn’t actually modify the existing <code>text</code> object—it sets the variable <code>myName</code> to refer to a new <code>text</code> object with a different value.</p></div> <div class="api specialConsiderations"><h5>Special Considerations</h5><p>For compatibility with versions prior to AppleScript 2.0, <code>string</code><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_635"></a> and <code>Unicode text</code><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_636"></a> are still defined, but are considered synonyms for <code>text</code>. For example, all three of these statements have the same effect:</p><div class="codesample clear"><table><tr><td scope="row"><pre>someObject as text<span></span></pre></td></tr><tr><td scope="row"><pre>someObject as string<span></span></pre></td></tr><tr><td scope="row"><pre>someObject as Unicode text<span></span></pre></td></tr></table></div><p>In addition, <code>text</code>, <code>string</code>, and <code>Unicode text</code> will all compare as equal. For example, <code>class of "foo" is string</code> is <code>true</code>, even though <code>class of "foo"</code> returns <code>text</code>. However, it is still possible for applications to distinguish between the three different types, even though AppleScript itself does not.</p><p>Starting with AppleScript 2.0, there is no style information stored with <code>text</code> objects.</p><p>Because all text is Unicode text, scripts now always get the Unicode text behavior. This may be different from the former <code>string</code> behavior for some locale-dependent operations, in particular <code>word</code> elements. To get the same behavior with 2.0 and pre-2.0, add an explicit <code>as Unicode text</code> coercion, for example, <code>words of (someText as Unicode text)</code>.</p><p>Because <code>text item delimiters</code> (described in <span class="content_text"><a href="../conceptual/ASLR_fundamentals.html#//apple_ref/doc/uid/TP40000983-CH218-SW22" data-renderer-version="1">text item delimiters</a></span>) respect <code>considering</code> and <code>ignoring</code> attributes in AppleScript 2.0, delimiters are case-insensitive by default. Formerly, they were always case-sensitive. To enforce the previous behavior, add an explicit <code>considering case</code> statement.</p><p>Because AppleScript 2.0 scripts store all text as Unicode, any text constants count as a use of the former <code>Unicode text</code> class, which will work with any version of AppleScript back to version 1.3. A script that contains Unicode-only characters such as Arabic or Thai will run, but will not be correctly editable using versions prior to AppleScript 2.0: the Unicode-only characters will be lost.</p></div><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW8" title="unit types"></a><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_637"></a><div class="content_ref_head_code">unit types</div><p>Used for working with measurements of length, area, cubic and liquid volume, mass, and temperature.</p><p>The unit type classes support simple objects that do not contain other values and have only a single property, the <code>class</code> property.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-SW14" title="Properties of unit type objects"></a><h5>Properties of unit type objects</h5><table border="0" cellpadding="0" cellspacing="1" width="100%"><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_638"></a><tr><td valign="bottom" height="30" colspan="5" scope="row"><code>class</code></td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Access:</td><td valign="top" height="10" class="content_text" colspan="3">read only</td></tr><tr><td width="10" scope="row"> </td><td valign="top" height="10" width="65" class="content_text">Class:</td><td valign="top" height="10" class="content_text" colspan="3">(varies; listed below)</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text">The class identifier for the object. These are the available classes:</td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><em class="newTerm">Length:</em> <code>centimetres</code>, <code>centimeters</code>, <code>feet</code>, <code>inches</code>, <code>kilometres</code>, <code>kilometers</code>, <code>metres</code>, <code>meters</code>, <code>miles</code>, <code>yards</code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><em class="newTerm">Area:</em> <code>square feet</code>, <code>square kilometres</code>, <code>square kilometers</code>, <code>square metres</code>, <code>square meters</code>, <code>square miles</code>, <code>square yards</code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><em class="newTerm">Cubic volume:</em> <code>cubic centimetres</code>, <code>cubic centimeters</code>, <code>cubic feet</code>, <code>cubic inches</code>, <code>cubic metres</code>, <code>cubic meters</code>, <code>cubic yards</code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><em class="newTerm">Liquid volume:</em> <code>gallons</code>, <code>litres</code>, <code>liters</code>, <code>quarts</code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><em class="newTerm">Weight:</em> <code>grams</code>, <code>kilograms</code>, <code>ounces</code>, <code>pounds</code></td></tr><tr><td width="10" scope="row"> </td><td valign="bottom" height="20" colspan="4" class="content_text"><em class="newTerm">Temperature:</em> <code>degrees Celsius</code>, <code>degrees Fahrenheit</code>, <code>degrees Kelvin</code></td></tr></table><br/><br/><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_60" title="Operators"></a><h5>Operators</h5><p>None. You must explicitly coerce a unit type to a number type before you can perform operations with it.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_61" title="Coercions Supported"></a><h5>Coercions Supported</h5><p>You can coerce a unit type object to <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCHBDCJ" data-renderer-version="1">integer</a></code>, single-item <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCDBHIE" data-renderer-version="1">list</a></code>, <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCJECEC" data-renderer-version="1">real</a></code>, or <code><a href="#//apple_ref/doc/uid/TP40000983-CH1g-BBCIAHJF" data-renderer-version="1">text</a></code>. You can also coerce between unit types in the same category, such as <code>inches</code> to <code>kilometers</code> (length) or <code>gallons</code> to <code>liters</code> (liquid volume). As you would expect, there is no coercion between categories, such as from <code>gallons</code> to <code>degrees Centigrade</code>.</p><a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_62" title="Examples"></a><h5>Examples</h5><p>The following statements calculate the area of a circle with a radius of 7 yards, then coerce the area to square feet:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set circleArea to (pi * 7 * 7) as square yards --result: square yards 153.9380400259<span></span></pre></td></tr><tr><td scope="row"><pre>circleArea as square feet --result: square feet 1385.4423602331<span></span></pre></td></tr></table></div><p>The following statements set a variable to a value of 5.0 square kilometers, then coerce it to various other units of area:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set theArea to 5.0 as square kilometers --result: square kilometers 5.0<span></span></pre></td></tr><tr><td scope="row"><pre>theArea as square miles --result: square miles 1.930510792712<span></span></pre></td></tr><tr><td scope="row"><pre>theArea as square meters --result: square meters 5.0E+6<span></span></pre></td></tr></table></div><p>However, you cannot coerce an area measurement to a unit type in a different
category:</p><div class="codesample clear"><table><tr><td scope="row"><pre>set theArea to 5.0 as square meters --result: square meters 5.0<span></span></pre></td></tr><tr><td scope="row"><pre>theArea as cubic meters --result: error<span></span></pre></td></tr><tr><td scope="row"><pre>theArea as degrees Celsius --result: error<span></span></pre></td></tr></table></div><p>The following statements demonstrate coercion of a unit type to a <code>text</code> object:<a name="//apple_ref/doc/uid/TP40000983-CH1g-DontLinkElementID_639"></a></p><div class="codesample clear"><table><tr><td scope="row"><pre>set myPounds to 2.2 as pounds --result: pounds 2.2<span></span></pre></td></tr><tr><td scope="row"><pre>set textValue to myPounds as text --result: "2.2"<span></span></pre></td></tr></table></div>
<div id="pageNavigationLinks_bottom" class="pageNavigationLinks">
<a class='nextLink' rel='next' href='ASLR_cmds.html'>Next</a><a class='previousLink' rel='prev' href='../conceptual/ASLR_about_handlers.html'>Previous</a>
</div><br/>
<div class="copyright"><br/><hr /><div align="center"><p class="content_text" lang="en" dir="ltr"> Copyright © 2016 Apple Inc. All Rights Reserved. <a href="http://www.apple.com/legal/internet-services/terms/site.html" target="_blank">Terms of Use</a> | <a href="http://www.apple.com/privacy/" target="_blank">Privacy Policy</a> | Updated: 2016-01-25</p></div></div>
<div id="pediaWindow">
<div id="pediaHeader"></div>
<div id="pediaBody"></div>
</div>
</article>
<div id="blackout">
<div id="preload"></div>
</div>
<div id="modal" aria-hidden="true">
<div id="closebox" tabindex="0" aria-label="Close feedback form" role="button"></div>
<div id="sending" class="hidden">
<h2 tabindex="0">Sending feedback…</h2>
<div id="sending_img"></div>
</div>
<div id="error" class="hidden">
<h2 tabindex="0">We’re sorry, an error has occurred.</h2>
<p>Please try submitting your feedback later.</p>
<div id="error_icon"></div>
</div>
<div id="success" class="hidden">
<h2 tabindex="0">Thank you for providing feedback!</h2>
<p>Your input helps improve our developer documentation.</p>
<div id="thank_you_icon"></div>
</div>
<form id="feedback" action="#" method="post">
<div class="left-leaf">
<h2 id="helpful_title" data-asterisk="a1" tabindex="0">How helpful is this document?</h2>
<sup id="a1" class="asterisk" aria-hidden="true">*</sup>
<div id="star_group" role="radiogroup" aria-required="true">
<label>
<input class="radio" type="radio" name="helped" value="1" />
Very helpful
</label>
<label>
<input class="radio" type="radio" name="helped" value="2" />
Somewhat helpful
</label>
<label>
<input class="radio" type="radio" name="helped" value="3" />
Not helpful
</label>
</div>
</div>
<div class="right-leaf">
<h2>How can we improve this document?</h2>
<div id="improve" class="checkboxes">
<label>
<input type="checkbox" name="typo" />
Fix typos or links
</label>
<label>
<input type="checkbox" name="infoIncorrect" />
Fix incorrect information
</label>
<label>
<input type="checkbox" name="needs_examples" />
Add or update code samples
</label>
<label>
<input type="checkbox" name="needs_art" />
Add or update illustrations
</label>
<label>
<input type="checkbox" name="missingInfo" />
Add information about...
</label>
</div>
</div>
<textarea id="comment" name="problem" cols="70" rows="8" placeholder="Please tell us more about your experience with this document" data-asterisk="a2" required></textarea>
<sup id="a2" class="asterisk" aria-hidden="true">*</sup>
<p class="fineprint">
<em aria-hidden="true"><span>*</span> Required information</em>
</p>
<input id="submit" type="button" value="Send" />
<section id="legal">
<p>
To submit a product bug or enhancement request, please visit the
<a href="https://developer.apple.com/bugreporter/" target="_blank">Bug Reporter</a>
page.
</p>
<p>
Please read <a href="http://www.apple.com/legal/policies/ideas.html" target="_blank">Apple's Unsolicited Idea Submission Policy</a>
before you send us your feedback.
</p>
</section>
</form>
</div>
<script charset="utf-8" src="../../../../../Resources/1282/JavaScript/lib/prototype.js"></script>
<script src="../../../../../Resources/1282/JavaScript/library.js"></script>
</body>
</html>