How to fix Syntax Error: Expected end of line, etc. but found end of script. in applescript?

I am making an applescript for my modding tool for Minecraft. It used to use multiple apps and I am now trying to make one app for all the tasks.
Here is the code:
say "You are running iCraft version one point one for minecraft version 1.2.5"
display dialog "Which tool do you want to use?" buttons {"Mod Installer", "Backup", "Restore"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Mod Installer" then
do shell script "~/desktop/iCraft/iCraft.app/contents/re…
display dialog "Insert all mod files into the Mods folder."
display dialog "Have you inserted all Mod files into the Mods folder?" buttons {"Yes", "No"} default button 2
if the button_pressed is "Yes" then
do shell script "~/desktop/iCraft/iCraft.app/contents/re…
display dialog "Finished"
else
display dialog "Insert mod files into the Mods folder and restart iCraft.app."
end if
if the button_pressed is "Backup" then
display dialog "Are you sure you want to backup your Minecraft.jar in it's current state?" buttons {"Yes", "No"} default button 2
if the button_pressed is "Yes" then
do shell script "~/desktop/iCraft/iCraft.app/contents/re…
display dialog "Finished, find it in your Backups directory in the iCraft folder"
else
display dialog "Backup aborted"
end if
if the button_pressed is "Restore" then
display dialog "Are you sure you want to restore your Minecraft.jar with your backup?" buttons {"Yes", "No"} default button 2
if the button_pressed is "Yes" then
do shell script "~/desktop/iCraft/iCraft.app/resources/s…
else
display dialog "Restore aborted"
end if
end
When I try to compile/run it gives me Syntax Error: Expected end of line, etc. but found end of script.

Your script got mangled when pasting it into your message, but the main problem looks like you are missing a bunch of end if statements.  Unless your if statements are contained on one line, you need to terminate them with a matching end if statement - for example, the following are equivalent:
if someString is "whatever" then display dialog "foo"
if someString is "whatever" then
  display dialog "foo"
end if

Similar Messages

  • "Expected end of line, etc. but found end of script." HELP!!

    When I try to run my script, it say "(null.)" When I try to compile it or save it as an application, it says "Expected end of line, etc. but found end of script." HELP!!!
    Here is my script:
    display dialog "WARNING! a virus has been detected and the system is crashing" buttons {"shut down computor to preserve contents", "burn virus file"} default button 2
    if the button returned of the result is "burn virus file" then
    say "warning the virus has reacted to its deletion and has activated itself"
    say "virus is now in control of the users computor"
    say "if you try to stop the virus it will delete all user data"
    tell application "Safari"
    activate
    open location "http://www.facebook.com"
    open location "http://www.yahoo.com"
    open location "http://www.gmail.com"
    open location "http://www.youtube.com"
    end tell
    tell application "iTunes"
    activate
    play
    end tell
    tell application "iCal"
    activate
    end tell
    tell application "Terminal"
    activate
    end tell
    tell application "Finder"
    quit
    end tell
    if the button returned of the result is "shut down computor to preserve contents" then
    say "your computor will shut to protect your files."
    say "shut down in t-3"
    say "2."
    say "1."
    say "goodbye"
    say "it appears that there is a problem"
    say "the virus is starting to take over your system"
    beep 17
    display dialog "how DARE you try to delete me. I am now going to take over your computer." buttons {"**** YOU GET OUTTA MY COMPUTER", "OK, have fun!!"} default button "OK, have fun!!"
    if the button returned of the result is "OK, have fun!!" then
    say "thank you!!"
    say "watch this!"
    Tell application "iChat"
    quit
    end tell
    Tell application "Finder"
    quit
    end tell
    if the button returned of the result is "**** YOU GET OUTTA MY COMPUTER" then
    say "That attitude will not be tollerated."
    say "Dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo" using "Cellos"
    display dialog "A virus has been detected going through your files. Would you like to try to stop this?" buttons {"OK"} default button "OK"
    if the button returned of the result is "OK" then
    beep 5
    display dialog "there has been an error. Do you want to try to force quit?" buttons "Yes" default button "Yes"
    if the button returned of the result is "Yes" then
    say "Well, thats just too bad!"
    beep 2
    say "Sorry about that."
    say "The virus has been purged from your system."
    say "Your computer will now restart to make sure that all traces of the virus have been removed."
    say "shut down in t-3"
    say "2"
    say "1"
    say "goodbye"
    tell application "Finder"
    restart
    end tell
    end if

    You need to complete compound if statements with an end if - see the AppleScript Language Guide for a description of the various kinds of if statements.
    Although I don't think it is going to do what you expect, your script would look something like:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    display dialog "WARNING! a virus has been detected and the system is crashing" buttons {"shut down computor to preserve contents", "burn virus file"} default button 2
    if the button returned of the result is "burn virus file" then
    say "warning the virus has reacted to its deletion and has activated itself"
    say "virus is now in control of the users computor"
    say "if you try to stop the virus it will delete all user data"
    tell application "Safari"
    activate
    open location "http://www.facebook.com"
    open location "http://www.yahoo.com"
    open location "http://www.gmail.com"
    open location "http://www.youtube.com"
    end tell
    tell application "iTunes"
    activate
    play
    end tell
    tell application "iCal"
    activate
    end tell
    tell application "Terminal"
    activate
    end tell
    tell application "Finder"
    quit
    end tell
    else if the button returned of the result is "shut down computor to preserve contents" then
    say "your computor will shut to protect your files."
    say "shut down in t-3"
    say "2."
    say "1."
    say "goodbye"
    say "it appears that there is a problem"
    say "the virus is starting to take over your system"
    beep 17
    end if
    display dialog "how DARE you try to delete me. I am now going to take over your computer." buttons {"**** YOU GET OUTTA MY COMPUTER", "OK, have fun!!"} default button "OK, have fun!!"
    if the button returned of the result is "OK, have fun!!" then
    say "thank you!!"
    say "watch this!"
    tell application "iChat"
    quit
    end tell
    tell application "Finder"
    quit
    end tell
    else if the button returned of the result is "**** YOU GET OUTTA MY COMPUTER" then
    say "That attitude will not be tollerated."
    say "Dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo" using "Cellos"
    end if
    display dialog "A virus has been detected going through your files. Would you like to try to stop this?" buttons {"OK"} default button "OK"
    if the button returned of the result is "OK" then
    beep 5
    display dialog "there has been an error. Do you want to try to force quit?" buttons "Yes" default button "Yes"
    else if the button returned of the result is "Yes" then
    say "Well, thats just too bad!"
    beep 2
    say "Sorry about that."
    say "The virus has been purged from your system."
    say "Your computer will now restart to make sure that all traces of the virus have been removed."
    say "shut down in t-3"
    say "2"
    say "1"
    say "goodbye"
    tell application "Finder"
    restart
    end tell
    end if
    </pre>

  • Applescript compile fails with "Expected end of line, etc. but found identifier"

    Hi,
    I've written my first applescript to move messages in Micorosoft Outlook to a specific folder.  It is based on existing scripts I found on the internet.  However my version keeps failing to compile with the error "Expected end of line, etc. but found identifier".  I tried the exact same script on another Mac and it works.  I created a very simple version of the script to show the error.  All I am trying to do is get the current selected messages so I can move them:
    on run {}
        tell application "Microsoft Outlook"       
            set selectedMessages to current messages
        end tell
    end run
    and I still get the same errors on the word "messages" above.
    MAC is running OSX 10.9.4
    Microsoft Outlook for Mac 2011 - version 14.4.3 (140616)
    Since the script works on other computers the only thing I can assume is something wrong with the setup.
    Any help is greatly appreciated.
    - Ben

    Frank Caggiano wrote:
    twtwtw
    Any reason that the parens would be needed on some cases and not in others? As you can see the code the OP posted compiled fine on my system with no need of the parens. Also the OP mentioned that the code did work on one machine but not another so I would assume again the parens were not needed in that case.
    JUst curious
    regards
    Parentheses have the same function here as they do in mathematical equations. They are cues to the compiler about the order in which different parts of the statement should be processed. The problem here, I think, is that the word current is part of a lot of applescript nouns: current date, current application, current messages, current user, current track, current location, etc. That's exacerbated by the fact that message is also a noun in its own right in Outlook, creating an ambiguous bit of grammar. Applescript has to interpret the presence of that word in context, and several factors - different versions of the OS or of the relevant applications, the presence of different osaxen, runtime issues that alter how the Applescript system reads in the scriptability information - could affect how that interpretation plays out.
    Context is (apparently) everything, sometimes.

  • Can anyone tell me how to fix this error I am receiving: LabView: File not found. VI "Mobile Display.vi" was stopped at unknown " " at a call to "Mobile Display.vi"?

    Can someone help me please? I am receiving this error everytime I attempt to execute my application:
    LabView: File not found. The file might have been moved or deleted, or the file path might be incorrectly formated for the operating system. For example, use \ as path separators on Windows, : on Mac OS, and / on Linux. Verify that the path is correct using the command prompt or file explorer.
    VI "Mobile Display.vi" was stopped at unknown " " at a call to "Mobile Display.vi"
    Attachments:
    labview error.jpg ‏176 KB

    We cannot help without additional information:
    Are you running your code
    ...in the development system?
    ...as a standalone application?
    ...deployed to an embedded target?
    If it is a built application, do you explicitly include dynamically called VIs in the build specification?
    Who wrote the program? Do you have access to the code?
    How is this VI called? Is there sufficient error handling?
    Do you manipulate paths as strings or as proper path datatypes with the strip path/build path primitives etc.?
    Is it running on the same OS used to develop it ...
    LabVIEW Champion . Do more with less code and in less time .

  • Syntax Error: Expected end of line but found end of script.

    display dialog "Are you awesome" buttons {"Yes", "No"} default button 1
    if the button returned of the result is "Yes" then
    tell application "Finder"
    display dialog "You Passed the Test" buttons {"YAY", "Poop nugets"} default button 1
    end tell
    display dialog "Cool" buttons {"Ok", "More Info"} default button 1
    if the button returned of the result is "More Info" then
    tell application "Finder"
    display dialog "You are obviously are awesome,
    100% Cool" buttons {"Ok"} default button 1
    end tell
    Then it says:
    Syntax error: Expected end of line but found end of script.

    can somebody fix this scrip becasue i am having the exact same problems
    tell application "SpeechRecognitionServer"
              set theResponse to listen for {"yes", "no"} with prompt "Hello Michael, Would you like the internet?"
              if theResponse is "yes" then
                        launch application "Google Chrome"
                        tell application "SpeechRecognitionServer"
                                  set theResponse to listen for {"yes", "no"} with prompt "What about a Calander?"
              if theResponse is "yes" then
                        launch application "ical"
                        tell application "SpeechRecognitionServer"
                                  set theResponse to listen for {"yes", "no"} with prompt "How about some iTunes Music?"
              if theResponse is "yes" then
                        launch application "itunes"
                        tell application "SpeechRecognitionServer"
                                  set theResponse to listen for {"yes","no"} with prompt "Would you like me to stop?"
              if theResponse is "no" then
                                  say "ok"
    else
              if theResponse is "no" then
                        exit repeat
    else
                                  exit repeat
    end
    end if
    end
    end if
    end
    end if
    end tell 

  • Line 26 1084:  Syntax Error:  expecting rightbrace before end of program

    Im trying to do an animation, how do I solve Line 26 1084:  Syntax Error:  expecting rightbrace before end of program?
    package
        import flash.display.MovieClip;
        import flash.utils.Timer;
        import flash.events.TimerEvent;
        public class AvoiderGame extends MovieClip
            public var enemy:Enemy;
            public var gameTimer:Timer;
            public function AvoiderGame()
                    enemy = new Enemy();
                    addChild( enemy );
                    gameTimer = new Timer( 25 );
                    gameTimer.addEventListener( TimerEvent.TIMER, moveEnemy );
                    gameTimer.start();
            public function moveEnemy( timerEvent:TimerEvent ):void
               enemy.moveDownABit();

    I have taken your advice but now 2 errors have popped up. Line 16 1137: Incorrect number of arguments . Expected no more than 0. Line 18 1120 : Access of undefined property enemy.
    package
        import flash.display.MovieClip;
        import flash.utils.Timer;
        import flash.events.TimerEvent;
        public class AvoiderGame extends MovieClip
            public var army:Array;
            public var avatar:Avatar;
            public var gameTimer:Timer;
            public function AvoiderGame()
                    army = new Array();
                    var newEnemy = new Enemy( 100, -15 );
                    army.push( newEnemy );
                    addChild( enemy );
                    avatar = new Avatar();
                    addChild( avatar );
                    avatar.x = mouseX;
                    avatar.y = mouseY;
                    gameTimer = new Timer( 25 );
                    gameTimer.addEventListener( TimerEvent.TIMER, onTick );
                    gameTimer.start();
            public function onTick( timerEvent:TimerEvent ):void
                avatar.x = mouseX;
                avatar.y = mouseY;
                for each ( var enemy:Enemy in army )
                         enemy.moveDownABit();
                         if ( avatar.hitTestObject( enemy ) )
                                    gameTimer.stop();

  • AppleScript -  Syntax Error: Expected end of line found """.

    The following AppleScript code works on Tiger and Snow Leopard but not on Leopard (10.5 > 10.5.8).
    tell application "FileMaker Pro"
    tell database "SomeDB.fp5"
    -- some code to execute
    end tell
    end tell
    In Leopard, the code won't compile and is complaining of a Syntax Error: Expected end of line found """. I click OK and then the quote symbol ( " ) to the left of SomeDB.fp5 is highlighted.
    Has anyone else experienced this and have resolved this in Leopard?
    Thanks

    If you copy/pasted the script from somewhere, the line endings in the source may not be translating. Try replacing the line endings (the return) on the lines around the one that is being highlighted.

  • 1084: Syntax error: expecting rightbrace before end of program.

    So I'm doing this basic coding thing to make an object "shoot" bullets. It's from a tutorial video. My code matches his exactly unless I'm missing a tiny detail. Basically the code looks like this:
    package {
    import flash.display.Sprite;
    import flash.events.Event; 
    public class bullet extends Sprite {
    private var sw:Number;
    private var sh:Number;
    private const _SPEED:int=-10;
    private const _OFFSTAGE:int=-10; 
    public function bullet():void {
    addEventListener(Event.ADDED_TO_STAGE,onadd);
    private function onadd(e:Event):void {
    sw=stage.stageWidth;
    sh=stage.stageHeight;
    addEventListener(Event.ENTER_FRAME,loop);
    private function loop(e:Event):void {
    if (y<_OFFSTAGE) {
    removeEventListener(Event.ENTER_FRAME,loop);
    parent.removeChild(this);
    y-=_SPEED;
    }public function removeListeners():void {
    removeEventListener(Event.ENTER_FRAME,loop); 
    And the compiler error I'm getting says this:
    Location:bullet.as line 31 1084: Syntax error: expecting rightbrace before end of program. Source: }
    Location:bullet.as line 31 1084: Syntax error: expecting rightbrace before end of program. Source: }
    And yes it does say it twice. What's going on?
    The vid I'm learning from is this: http://autocad.spinelink.com/adobe-flash-cs4-game-tutorial-shooting.html

    You are missing two closing curly braces at the bottom of the package declaration. You need to close the package itself and the class declaration inside.
    package {
         import flash.display.Sprite;
         import flash.events.Event;
         public class bullet extends Sprite {
              private var sw:Number;
              private var sh:Number;
              private const _SPEED:int=-10;
              private const _OFFSTAGE:int=-10;
              public function bullet():void {
                   addEventListener(Event.ADDED_TO_STAGE,onadd);
              private function onadd(e:Event):void {
                   sw=stage.stageWidth;
                   sh=stage.stageHeight;
                   addEventListener(Event.ENTER_FRAME,loop);
              private function loop(e:Event):void {
                   if (y<_OFFSTAGE) {
                        removeEventListener(Event.ENTER_FRAME,loop);
                        parent.removeChild(this);
                   y-=_SPEED;
              public function removeListeners():void {
                   removeEventListener(Event.ENTER_FRAME,loop);

  • 1084:Syntax error: expecting rightparen before area in Math.round

    Anyone have any idea how to fix this:
    theText.scrollV = Math.round((slider.y – area.y)*theText.maxScrollV/90);
    I'm getting error:
    1084:Syntax error: expecting rightparen before area.
    It looks like a proper statement to me... all open brackets are closed.
    Please HELP!!!

    OMG - I copied the code from a post and didn't see that. Good for you!
    Thanks!!!

  • Workaround for "Expected expression but found end of line" error

    I have the following code
    tell application "Mail"
    set mymailList to {"[email protected]", "[email protected]", "[email protected]"}
    set myattachmentList to {"Macintosh HD:Users:SAM:Desktop:A1.xls", "Macintosh HD:Users:SAM:Desktop:A2.xls", "Macintosh HD:Users:SAM:Desktop:A3.xls"}
    set n to count items in mymailList
    set i to 0
    repeat n times
    set i to i + 1
    set var1 to item i of mymailList
    set var2 to item i of myattachmentList as alias
    set newmessage to make new outgoing message with properties {visible:true, subject:"Report", content:"Blah Blah Blah"}
    tell newmessage
    set sender to "Sam <[email protected]>"
    set visible to true
    make new to recipient at end of to recipients with properties {address:var1}
    tell content to make new attachment with properties {file name:var2} at after last paragraph
    end tell
    activate
    send newmessage
    end repeat
    end tell
    I would like to be able to paste the MailList and MailAttatchmentList values from a spreadsheet so that it would look something like this:
    tell application "Mail"
    set mymailList to {
    "[email protected]",
    "[email protected]",
    "[email protected]"
    set myattachmentList to {
    "Macintosh HD:Users:SAM:Desktop:A1.xls",
    "Macintosh HD:Users:SAM:Desktop:A2.xls",
    "Macintosh HD:Users:SAM:Desktop:A3.xls"
    set n to count items in mymailList
    set i to 0
    repeat n times
    set i to i + 1
    set var1 to item i of mymailList
    set var2 to item i of myattachmentList as alias
    set newmessage to make new outgoing message with properties {visible:true, subject:"Report", content:"Blah Blah Blah"}
    tell newmessage
    set sender to "Sam <[email protected]>"
    set visible to true
    make new to recipient at end of to recipients with properties {address:var1}
    tell content to make new attachment with properties {file name:var2} at after last paragraph
    end tell
    activate
    send newmessage
    end repeat
    end tell
    Is there something that I can put at the end of each value so that I avoid the "Expected expression but found end of line" error?
    Thanks!
    Sam

    You didn't need to post the entire script - just an example of the list format would have done
    Anyway, AppleScript uses option-return as a 'soft' return/line continuation character, so:
    set mymailList to {¬
    "[email protected]",¬
    "[email protected]",¬
    "[email protected]
    (where ¬ indicates an option-return) will work. I'm just not sure off hand how you'd automatically insert option-return characters coming out of Excel...

  • Getting error... 1084: Syntax error: expecting leftperan before colon?

    I am trying to learn flash and make forms with them.
    I keep getting this error... 1084: Syntax error: expecting leftperan before colon
    here is my code
    function sent:(e:Event):void
    why am I getting this error?

    oh... silly me.
    Its fixed...
    function sent(e:Event):void
    Sorry

  • 1086: Syntax error: expecting semicolon before rightparen. ?

    Hi there i'm currently working on my year 13 ICT coursework using Adobe flash CS5.5 and while correcting an error while implementing a third party found image gallery another one appeared, which I am completely unable to fix.
    At the moment I would like the image gallery to be implemented in Scene 3 of my product, but it seems when opening to view the product it just spams through all the scenes and I am confused on why this is the case?
    If anyone can help with this then it would be much appreciated.
    Here is the code line which has the Syntax error, if any other thing are needed please just ask.
    lastBildeHL.onLoadProgress = gotoAndPlay("Scene 1")); numBytesLoaded:Number, numBytesTotal:Number):void
    Thanks

    Hi there just added that line and when doing so I then got these errors:
    Scene 3, Layer 'actions', Frame 5, Line 131
    1084: Syntax error: expecting rightparen before colon.
    Scene 3, Layer 'actions', Frame 5, Line 131
    1078: Label must be a simple identifier.
    Scene 3, Layer 'actions', Frame 5, Line 132
    1084: Syntax error: expecting identifier before var.
    Scene 3, Layer 'actions', Frame 5, Line 132
    1078: Label must be a simple identifier.
    Here are the actions:
    lastBildeHL.onLoadProgress = gotoAndPlay("Scene 1", numBytesLoaded:Number, numBytesTotal:Number):void
        var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
    Any help would be good
    Thanks,
    Joe

  • Does anyone know how to fix an error in cc photoshop on Win8 that says puppet warp could not complete request due to program error?

    Does anyone know how to fix an error in cc photoshop on Win8 that says puppet warp could not complete request due to program error?

    Questions on using a specific program should go in that program forum
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • Lightroom crashes at start up with the error message "Lightroom encountered an error when reading from its preview cache and needs to quit".  Please advise on how to fix this error.  Thanks

    Lightroom crashes at start up with the error message "Lightroom encountered an error when reading from its preview cache and needs to quit".  Please advise on how to fix this error.  Thanks

    You probably need to delete your preview cache.  See here  
    Why And How To Clear Your Lightroom Cache - Lightroom Fanatic
    Preference and other file locations in Lightroom 5

  • How to fix this error message The backup disk image "/Volumes/AirPort Disk/FARES DEL VALLE's iMac.sparsebundle" could not be accessed (error -1).

    how to fix this error message The backup disk image “/Volumes/AirPort Disk/FARES DEL VALLE’s iMac.sparsebundle” could not be accessed (error -1).

    The troubleshooting C17 is the specific article.
    http://pondini.org/TM/Troubleshooting.html
    This is generally a Lion error.. and you will need 5.6 utility to get access to the disk area.
    So download the real utility. Run it instead of v6 toy version.
    http://support.apple.com/kb/DL1482
    Go to the manual setup, disk page and click on disconnect all users.. that will unmount all users connected to the disk and allow it to start working. But there are a number of other issues that are possible cause. Pondini lists some of them.

Maybe you are looking for

  • List of reminder that can snooze or dismiss similar to Outlook or Gminder

    Hi there, Does anybody know how to setup iCal or another product that works similar to Outlook reminder popup window in windows? I'm looking for a window where you can see a list of reminders from the calendar events that later on you can snooze or d

  • HP LaserJet 1200 Series + Updates

    I recently tried to update the driver of my printer (HP LaserJet 1200). After countless (manual) uninstalls and reinstalls, messing around in Terminal, i.a., I still cannot get Mac OS X 10.5 to recognize the new driver. If anyone is knowledgeable in

  • Can one copy a text layer's content to the clipboard?

    I have searched for this but have been unsuccessful in doing so...I want to be able to either;    a: copy the contents of a text layer to the clipboard so that when saving a file I can simply paste and save or...    b: save a file by the contents in

  • Changing self registration fields

    Does any one know how to change the labels on the self registration page. I would like to change one of the titles to say location or can I add a field for input?

  • Increasing Database Size

    Hi, I am working in oracle9i and Linux 2.4.I created a Database of size 0.7 GB. I want to increase the size of the Database to 5Gb. Please explain me the SQL query. Gobi.