19.6. Considering/IgnoringThere are two kinds of considering/ignoring block. One is the "ignoring application responses" block, which affects the nature of Apple events targeting an application. The other affects the details of string comparisons. 19.6.1. Ignoring Application Responses
Recall from "Apple Events" in Chapter 3 that during interapplication communications the sender of an Apple event may specify that it has no
ignoring application responses
--
code
end ignoring
Within the block, only Apple events sent to other applications are affected. Apple events sent to scripting additions, for example, are sent in the normal way and receive whatever replies they normally receive.
For an example, see "Reduction" in Chapter 1. The code that opens a URL from the clipboard is wrapped in an "ignoring application responses" block, because I want the browser or mail client or whatever to
Inside an "ignoring application responses" block, it is possible to override the block by embedding a "considering application responses" block. You might use this construct, for example, to ignore responses from one application but not another. 19.6.2. String Considerations
String considerations
are optional switches that govern the nature of a string comparison (see "Comparison Operators" and "Containment Operators" in Chapter 15). For example, string comparison may be case-sensitive or case-insensitive. You can use a considering/ignoring block to
Until recently there was no mechanism for making string considerations visible to a
Here are the string considerations:
Here's the syntax for writing a string consideration:
considering ignoring
considerations
[but ignoring considering
considerations
]
--
code
end considering ignoring
Each set of considerations is any number of string considerations separated by comma; AppleScript will rewrite the last comma as and . Entire string consideration blocks may also be nested. So, for example:
ignoring hyphens, expansion and punctuation
considering white space but ignoring case and diacriticals
"a-" = "!" --
true
end considering
end ignoring
String considerations are Unicode-savvy:
set bigEpsilon to «data utxt0395» as Unicode text
set littleEpsilon to «data utxt03B5» as Unicode text
ignoring case
bigEpsilon = littleEpsilon --
true
end ignoring
Here's an example illustrating the new numeric strings consideration: "1.10" > "1.9.3" -- false considering numeric strings "1.10" > "1.9.3" -- true end considering In the comparison inside the considering block, 1 is equal to 1 so we proceed to the next section; 10 is greater than 9 so that's the result of the comparison. |