AppleScript works but returns an error?

Discussion in 'Mac Programming' started by TheMTtakeover, Jan 17, 2013.

  1. TheMTtakeover, Jan 17, 2013
    Last edited: Jan 17, 2013

    macrumors 6502

    Joined:
    Aug 3, 2011
    #1
    Okay the script is:

    Code:
    tell application "SkyDrive"
    	quit
    end tell
    set the_button to button returned of (display dialog "Did Skydrive close?" buttons {"Yes", "No"} default button 1)
    if the_button is "Yes" then tell application "Terminal"
    	activate
    	do script "cp -av /Users/osx/Desktop/test /Users/osx/Desktop/untitled folder"
    end tell
    if the_button is "No" then display dialog "Please Try Again"
    delay 2
    set button_two to button returned of (display dialog "Was the copy successful?" buttons {"Yes", "No"} default button 1)
    if button_two is "Yes" then tell application "SkyDrive"
    	activate
    end tell
    if button_two is "No" then display dialog "Please Try Again"
    It works fine until when I hit yes that the copy was successful.SkyDrive doesn't start and an error pops up, but then after the error pops up SkyDrive starts. So it has me kind of puzzled because it does work but it just needs the error to pop up first?

    the error is:
    error "SkyDrive got an error: AppleEvent timed out." number -1712

    Any help would be greatly appreciated!
     
  2. macrumors G4

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    The problem may be that SkyDrive is taking longer than AppleScript is willing to wait for it. If that's the case, you could fiddle with the time out value - but I have no idea how you set that globally, only for dialog boxes.
     
  3. thread starter macrumors 6502

    Joined:
    Aug 3, 2011
    #3
    Thats what I thought so I changed the code:

    Code:
    if button_two is "Yes" then with timeout of 10 seconds
    	tell application "SkyDrive"
    		activate
    	end tell
    end timeout
    and no matter how many seconds I set the timeout for SkyDrive won't reopen until the error message pops up. I cannot figure this thing out at all
     
  4. thread starter macrumors 6502

    Joined:
    Aug 3, 2011
    #4
    If anybody comes across this having the same problem the only workaround I was able to find was running it through the terminal so it would end up being
    Code:
    tell application "SkyDrive"
    	quit
    end tell
    set button_one to button returned of (display dialog "Did Skydrive close?" buttons {"Yes", "No"} default button 1)
    if button_one is "Yes" then tell application "Terminal"
    	activate
    	do script "cp -av /Users/osx/SkyDrive /Volumes/Skydrive/$(date +%Y-%m-%d)"
    end tell
    if button_one is "No" then error number -128
    set button_two to button returned of (display dialog "Was the copy successful?" buttons {"Yes", "No"} default button 1)
    if button_two is "Yes" then tell application "Terminal"
    	do script "open -a SkyDrive"
    end tell
    if button_two is "No" then error number -128
     

Share This Page