select data to use in "Choose From List" list in applescript

Discussion in 'Mac Programming' started by ShuddaRunThat, Apr 1, 2014.

  1. ShuddaRunThat macrumors newbie

    Apr 1, 2014
    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
  2. kryten2, Apr 1, 2014
    Last edited: Apr 1, 2014

    kryten2 macrumors 6502a

    Mar 17, 2012
    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 :

    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

    Attached Files:

  3. ShuddaRunThat thread starter macrumors newbie

    Apr 1, 2014

Share This Page