1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Applescript error -1708?

Discussion in 'Mac Programming' started by ElectricMan5, May 24, 2009.

  1. macrumors regular

    #1
    I just finished building an Applescript application in Xcode, and whenever I click a button linked to a script i get an error:

    Applescript Error

    -1708


    I don't know what I'm doing wrong, and I can't find anyone else who's had this error. Thanks!
     
  2. macrumors regular

    #2
    I guess i'm the only one who has it...
     
  3. macrumors 68040

    lee1210

    #3
    Can you post the code? Surprisingly the apple site was not too forthcoming about this error, but the code that corresponds is errAEEventNotHandled, and a few other people described this occurring when a tell was sent to an app that was not scriptable, so that may be the case here.

    -Lee

    Edit: Some other posts suggest that if you have handlers set up in interface builder that do not have corresponding applescript code you might get this.
     
  4. macrumors regular

    #4
    Well, I did an extremely simple thing. I just assigned a button to an applescript which runs when clicked. This is the applescript:

    Code:
    tell application "Finder"
    	activate
    	open application file "World of Warcraft.app" of folder "World of Warcraft" of item ".Games" of item ".websitebackup" of folder "Desktop" of folder "Will" of folder "Users" of startup disk
    end tell

    It works perfectly when I run it, but it gives me the error in the full application. I think Xcode might be doing something wrong to it...
     
  5. macrumors 65816

    mysterytramp

    #5
    1) put the "open application file" inside a "try ... on error ... end try" block. Trap the error and see what changes.

    2) don't scripts inside Xcode buttons need to be inside "on run ... end run" blocks?

    mt
     
  6. macrumors regular

    #6
    I really don't know what you mean by that... Could you change my code to what your talking about?

    I don't know what you mean by the "..."

    Thanks :)
     
  7. macrumors 65816

    mysterytramp

    #7
    "..." means you fill in the blanks.

    try
    open application file "TextEdit"
    on error
    display dialog "Didn't work"
    end try

    OK?

    My previous post was wrong. It's not "on run," it's "on clicked." The script of your button should be:

    Code:
    on clicked theObject
      try
         open application file "TextEdit" -- I'll leave you to enter that lengthy path
      on error
         display dialog "Didn't work"
      end try
    end clicked
    I'm betting you got an errAEEventNotHandled error message because the button doesn't handle tell messages. It handles clicked messages. And you'll have to make sure in Xcode that the button is ready to accept clicked messages.

    mt
     
  8. macrumors regular

    #8
    I fixed it :)

    The correct code:

    Code:
    on clicked theObject
    	tell application "Finder"
    		activate
    		open application file "World of Warcraft.app" of folder "World of Warcraft" of item ".Games" of item ".websitebackup" of folder "Desktop" of folder "Will" of folder "Users" of startup disk
    	end tell
    end clicked
     
  9. macrumors regular

    #9

    Lol i fixed it before I saw your reply :) now that i look at it, you gave the same code also. I guess I found it myself :)
     

Share This Page