Re: if clauses: multiple values in one test?
Re: if clauses: multiple values in one test?
- Subject: Re: if clauses: multiple values in one test?
- From: Walter Ian Kaye <email@hidden>
- Date: Sun, 21 Sep 2003 00:14:30 -0700
At 12:34a +0200 09/21/2003, Mikael Bystrvm didst inscribe upon an
electronic papyrus:
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?
If you're on OS X, you can shell out for Perl.
Otherwise you could use a loop:
set ends to {"X", "Y", ".Z"}
repeat with e in ends
if FileName ends with e then
--do something
exit repeat
end if
end repeat
-boo
sleepy and not knowing if "shell out for" makes any english sense :)
_______________________________________________
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.