• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: if clauses: multiple values in one test?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: if clauses: multiple values in one test?


  • Subject: Re: if clauses: multiple values in one test?
  • From: Andrew Oliver <email@hidden>
  • Date: Sat, 20 Sep 2003 23:40:55 -0700

> You don't have to extract the last character to do the test. This
> works:
>
> if fileName ends with some item of {"X", "Y", "Z",...} then beep

Correct me if I'm wrong, but doesn9t this translate as:

if fileName ends with (some item of {"X", "Y", "Z", ...} then beep

i.e. AppleScript first selects (some item of {"X", "Y", "Z", ...}) and then
checks to see if the fileName ends with that character... i.e. You have a 1
in 26 chance of it matching. Not quite what the original poster was looking
for.

Andrew
:)


On 9/20/03 11:23 PM, "Marc K. Myers" <email@hidden> wrote:

>> Date: Sun, 21 Sep 2003 09:33:08 +1000
>> Subject: Re: if clauses: multiple values in one test?
>> From: Matthew Smith <email@hidden>
>> To: AppleScript Users <email@hidden>
>>
>> on 21/09/2003 08:34, Mikael Bystrvm at email@hidden
>> wrote:
>>
>>> How can I shorten a long line of nearly identical tests, except for
>>> the
>>> value it tests against, in an if clause?
>>> Say I have
>>> "if (FileName ends with "X") or (FileName ends with "Y") or (FileName
>>> ends with ".Z")....... (*plus 26 more or so*)
>>> then"
>>>
>>> Can I use an array of string values instead and have them all in only
>>> one
>>> test? How can I express that in this situation?
>>> Or can I at least write "with x or y or z" or similar in a simple way?
>>
>> Not when the test is 'ends with'. If you extract the ending before you
>> come
>> to the if condition you could write:
>>
>> if fileNameEnd is in {"X","Y",".Z"....} then
>>
>> In this case you are testing for equality with a value in a list.
>
> You don't have to extract the last character to do the test. This
> works:
>
> if fileName ends with some item of {"X", "Y", "Z",...} then beep
>
> Marc [09/21/03 2:23:38 AM]
> _______________________________________________
> applescript-users mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/applescript-users
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: if clauses: multiple values in one test?
      • From: Michelle Steiner <email@hidden>
References: 
 >Re: if clauses: multiple values in one test? (From: "Marc K. Myers" <email@hidden>)

  • Prev by Date: Re: if clauses: multiple values in one test?
  • Next by Date: Re: if clauses: multiple values in one test?
  • Previous by thread: Re: if clauses: multiple values in one test?
  • Next by thread: Re: if clauses: multiple values in one test?
  • Index(es):
    • Date
    • Thread