Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ShuddaRunThat

macrumors newbie
Original poster
Apr 1, 2014
5
0
Hi. This is an example of the problem I am trying to solve. I have a set of records with two fields such as {{name:"fred",mood:"happy"},{name:"jim",mood:"sad"},{name:"Joe",mood:"happy"}} what i need to do is create a "choose from list" dialog box that takes it list of options from this record list for all records where mood = happy. then I would know who has the mood of happy and could then change it to something else. i hope this makes sense. thanks
 
Hi. This is an example of the problem I am trying to solve. I have a set of records with two fields such as {{name:"fred",mood:"happy"},{name:"jim",mood:"sad"},{name:"Joe",mood:"happy"}} what i need to do is create a "choose from list" dialog box that takes it list of options from this record list for all records where mood = happy. then I would know who has the mood of happy and could then change it to something else. i hope this makes sense. thanks

The current version of AppleScript does not support the use of every...whose clauses when targeting lists.
Unless something had changed in recent versions of Applescript I'm not aware of.

Try this :

Code:
set myRecord to {{firstname:"Fred", mood:"happy"}, {firstname:"Jim", mood:"sad"}, {firstname:"Joe", mood:"happy"}, {firstname:"John", mood:"happy"}, {firstname:"Steve", mood:"happy"}, {firstname:"Bill", mood:"sad"}}

set newList to {}
repeat with anItem in myRecord
	if mood of anItem is "happy" then
		set end of newList to firstname of anItem
	end if
end repeat
return newList

--choose from list newList

Note : Also take a look at the List Suite from ASObjC Runner.
Info : ASObjC Runner — Vanilla Mode
 

Attachments

  • Picture 3.png
    Picture 3.png
    87.6 KB · Views: 213
  • Picture 5.png
    Picture 5.png
    100.2 KB · Views: 176
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.