5.5. The considering and ignoring Statements
You can use two special statements to control the way strings are compared: considering and ignoring. The considering statement enables you to specify an attribute to consider when comparing strings. The general format of the considering statement is the following:
considering attribute statement statement ... end considering
Any of the statements included within the considering block, up to the end considering, ignore the specified attribute when string comparisons or containment operations (explained shortly) are performed. When you exit the block, the previous considering/ignoring status of attribute is restored.
As a simple example, you can use the attribute case to specify that the program distinguishes between uppercase and lowercase letters when comparing two strings. Normally, case is not taken into consideration. That means, if you write the statement
log "yes" = "YES"
true is entered into the log because these two strings are normally considered equal. That is, the case of the letters is normally ignored. If you, instead, write the following
considering case log "yes" = "YES" end considering
false is entered into the log because the string "yes" is not equal to the string "YES" when uppercase and lowercase letters are considered as distinct letters.
The ignoring statement is the inverse of the considering statement: It enables you to specify an attribute to be ignored when comparing or searching strings. The general format ...
Get Beginning AppleScript® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.