DekGenius.com
[ Team LiB ] Previous Section Next Section

12.6 Considering/Ignoring

There 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.

12.6.1 Ignoring Application Responses

Recall from Section 4.1 that during interapplication communications, the sender of an Apple event may specify that it has no intention of waiting around for a reply. It doesn't care what the result is; it doesn't care if there's an error. It just wants to send the Apple event and be done with it, proceeding immediately to its own next step. In AppleScript, here's how to send such an Apple event:

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 Section 1.4. 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 open in the background and without my waiting for it; thus I can get on immediately with what I was doing.

Inside an "ignoring application responses" block, it is possible to override the block by embedding a "considering application responses" block. You might use this, for example, to ignore application responses from one application but not another.

12.6.2 String Considerations

String considerations are features of strings that may optionally come into play when performing a string comparison (see Section 15.3 and Section 15.4). For example, string comparison may be case-sensitive or case-insensitive. You use a considering/ignoring block to govern this behavior.

Until recently there was no mechanism for making string considerations visible to a targeted application. This meant that string considerations could operate only within AppleScript; a string comparison performed as part of a boolean test element specifier, for example, could not be affected by string considerations (see Section 10.7.8 and Section 15.7). This limitation has changed, but applications must be rewritten if they are to notice and take account of string considerations. See also Section 20.5.5 on the offset scripting addition command.

Here are the string considerations:


case

If ignored, uppercase and lowercase variants of the same letter are taken to be equivalent. Ignored by default.


diacriticals

If ignored, variants of the same letter with different accent marks (or no accent mark) are taken to be equivalent. Considered by default.


expansion

If ignored, ligatures are taken to be equivalent to their component characters. Considered by default.


hyphens

If ignored, hyphens are taken not to exist. Considered by default.


punctuation

If ignored, word-boundary punctuation and quotation marks and apostrophes are taken not to exist. Considered by default.


white space

If ignored, spaces, tabs, and line break characters are taken not to exist. Considered by default.

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
    [ Team LiB ] Previous Section Next Section