Re: An arbitrary if.
Re: An arbitrary if.
- Subject: Re: An arbitrary if.
- From: Shane Stanley <email@hidden>
- Date: Tue, 13 Sep 2011 11:00:17 +1000
Late as usual. Here's an AppleScriptObjC method that filters the list using containment as a test, and compares before and after.
set x to "this is a cat" set myList to {"this", "cat"} -- make test;%@ is replaced by value of x set aPredicate to current application's NSPredicate's predicateWithFormat_("%@ contains[cd] SELF", x) -- make array from list set myArray to current application's NSArray's arrayWithArray_(myList) -- filter array set newList to myArray's filteredArrayUsingPredicate_(aPredicate) -- compare before and after myList = newList as list
From the log:
00.0000 -- Start -- 00.0011 set x to "this is a cat" --> this is a cat 00.0005 set myList to {"this", "cat"} --> {this, cat} 00.0004 set aPredicate to current application's NSPredicate's predicateWithFormat_("%@ contains[cd] SELF", x) --> "this is a cat" CONTAINS[cd] SELF 00.0004 set myArray to current application's NSArray's arrayWithArray_(myList) --> {this, cat} 00.0004 set newList to myArray's filteredArrayUsingPredicate_(aPredicate) --> {this, cat} 00.0003 myList = newList as list --> true 00.0001 -- End -- (~0.017s)
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden