DekGenius.com
Team LiB   Previous Section   Next Section
constant

Allowed coercions

list with one item, as in {constant}
string (beginning in AppleScript Version 1.3.7)

Syntax

set theVar to pi (*theVar is set to the value of the pi constant, which is 
about 3.14159265359 *)

Description

AppleScript and scriptable applications include several constants or pre-defined variables that are based on the constant class. Chapter 6 includes more information on these constants.

Examples

case is a constant that in the following example will determine how strings are compared:

considering case
   set compString to ("I am" is equal to "i am")
end considering

This code sets the variable compString to false because the two strings are not equal considering the case of the string characters. The AppleScript constant case, if you test it using the code class of case, returns the constant class.

Many applications have defined their own constants using the constant value type. For example, Sherlock 2's current tab property will return one of the following Sherlock 2-defined constants (Find File Tab, Find by Content Tab, or Search Internet Tab):

tell application "Sherlock 2"
   set sh_tab to (get current tab)
   class of sh_tab -- returns constant
end tell

The return value of the current tab property is a constant identifying the Find File Tab, for instance. You can coerce this constant return value to a string, however, if you had to display the result using the display dialog scripting addition, which takes a string for a parameter (among other parameters). To coerce the return value of the previous example to a string you could use the code:

get current tab as string

    Team LiB   Previous Section   Next Section