Applescript problem...

Discussion in 'Mac Programming' started by orbdrums, Jun 8, 2015.

  1. orbdrums, Jun 8, 2015
    Last edited by a moderator: Jun 8, 2015

    orbdrums macrumors member

    Joined:
    Dec 13, 2008
    #1
    Hey all,

    Sorry if this post is in the wrong place but I just got culture shock from visiting this website. :)

    I have a REAL simple script that displays a list of options. The code is below:
    Code:
    choose from list {"Quick", "iMovie", "Standard", "Programming"} with prompt "Please select load option:"
    return the result as string
    set v_choice to result
    if v_choice is equal to "Quick" then
    beep 2
    end if
    if v_choice is equal to "iMovie" then
    tell application "iMovie" to activate
    end if
    if v_choice is equal to "Standard" then
    tell application "StandardLoad" to activate
    end if
    if v_choice is equal to "Programming" then
    tell application "EntertainmentLoad" to activate
    end if
    
    beep 4
    
    return
    The list works just fine but no action is taken when the choice is selected. In other words, regardless of the choice, there is no apparent action. Any help would be greatly appreciated.

    Wow, this site has changed!!!
     
  2. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    You are returning from the script before doing anything. Remove the line 'return the result as string' and move your coercion to the line after it: 'set v_choice to result as string' .
     
  3. orbdrums thread starter macrumors member

    Joined:
    Dec 13, 2008
    #3
    Thanks Red! You're suggestion made progress however, I don't know what you mean by "coercion".
     
  4. Red Menace macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #4
    For whatever reason, you were converting the result of the dialog to a string, so I just moved that from the deleted line.
     

Share This Page