How do I get a script to stop execution?

I'm brand new to scripting in Photoshop and coding in Java, and I need help. I want to ask the user a question and if they say "yes" I want the script to completely stop. If "no" I want it to continue.
Is there a way to do this? I've seen examples that look like this one below using "return", and they all say it will work. But all that does is stop the function, not the entire script.
=============
function EndScript() { 
    return; 
    alert('this line will never execute'); 
var PromptUser = confirm("Do you want to stop?");
     if(PromptUser ){
        EndScript();
alert("If the user clicks yes, I don't want this line to execute.");
=============
Isn't there some kind of statement that will just stop everything?
Thanks for your help.

By definition, return only leaves the function you are currently in, so you can't exit a part of the script that is not inside a function. What you are going to want to do is place the entire script inside a function, and then just call a return in the if statement. Such as:
function Script() {
    var PromptUser = confirm("Do you want to stop?");
    if(PromptUser ){
        return;
        alert('this line will never execute');
    alert("If the user clicks yes, I don't want this line to execute.");
Script();

Similar Messages

  • How do I get a song to stop at the end in garageband on ipad 2?

    When a song in Garageband (on ipad 2) reaches the end, it immediately loops back to the beginning and starts playing again. I'd like to use Garageband as an accompaniment to live performance. So, how do I get the song to stop (and not restart) at the end?

    I really wish the Apple team would fix this.  It's one of those nagging things that was overlooked, I would imagine, and no one but musicians that perform would notice.
    Anyway, my workaround is this.  I just put a really long silent space at the end of the song giving me time to stop it before it loops. 
    Hey ipad/garageband team -  How about a new release of gargageband?

  • How do you get your iPhone to stop connecting to face time while on a voice call? And it also does this when I'm on the phone with someone who doesn't have an iPhone. I look down at my phone while on a call and it says connecting to face time

    How do you get your iPhone to stop connecting to face time while on a voice call? And it also does this when I'm on the phone with someone who doesn't have an iPhone. I look down at my phone while on a call and it says connecting to face time

    How are you dialing these calls?

  • HT4993 How do you get your iPhone to stop connecting to face time while on a voice call? And it also does this when I'm on the phone with someone who doesn't have an iPhone. I look down at my phone while on a call and it says connecting to face time

    How do you get your iPhone to stop connecting to face time while on a voice call? And it also does this when I'm on the phone with someone who doesn't have an iPhone. I look down at my phone while on a call and it says connecting to face time

    How are you dialing these calls?

  • How can I get my iphone to stop losing the signal?

    How can I get my iphone to stop losing the signal?

    Thanks for the tip.  If only I could find somewhere where I did not lose the signal.
    I am based in the United Kingdom. The carrier is Orange.
    I lose the signal inside buildings and outside of buildings.  It happens at work and at home.  It happens in Centarl London in the open air and inside.  It happens in small towns.. It happens in the countryside.  It happens in motor cars.  It happens in airports.  It happens when the battery is fully charged, when it is half charged and when it's low on charge.  It happens using the phone, when reading messages and when using the internet.
    Hope this helps.

  • My Iphone 5 says it has 7552 songs on it, however my iTunes only has 4125 on it. How do i get my phone to stop saying i have that many songs?

    My Iphone 5 says it has 7552 songs on it, however my iTunes only has 4125 on it. How do i get my phone to stop saying i have that many songs?

    It seems to happen with songs that were purchased before synchronizing the new iPhone
    I will tell you how I fixed it.
    Note: I have iTunes in spanish so I will try to translate and figure out the commands that appear on ITunes in english. I will put my translations into brackets. English is not my native language. I will do my best.
    The workaround is:
    1.- Dragg no working songs from iTunes to a folder on the hard disk. (Only for backup purposes)
    2.- Deleted those songs from iTunes library.
    3.- On the left panel in ITunes click on "Purchased" under the STORE option. All your purchased songs will appear on the right panel
    4.- At the bottom and right there is the option : "Download Previous Purchases". Click there.
    5.- Click on the option "Are not in my Library" (top right)
    6.- The songs you deleted from iTunes will appear.
    7.- Downloaded them again. (You have the option to download at the bottom right)
    8.- Syncronize your iPhone and that's all.

  • I have 2 games Words with Friends and Cityville that receives a Pop-up message form iTunes...  "Connect to iTunes to use Push Notifications" and will not allow me to exit out of the app or play.  How can I get this message to STOP?

    I have 2 games Words with Friends and Cityville that receives a Pop-up message form iTunes...  "Connect to iTunes to use Push Notifications" and will not allow me to exit out of the app or play.  How can I get this message to STOP?

    Yes - I connected my phone to my computer / Itunes and went into the apps section, but from there I have no idea how to manage the push notifications.  I even tryied going into itunes that is installed on my phone.  I still cannot find anyplace to manage these popups.  I have also gone into settings - notifiations - and tried turning all notifications for these apps all off but that didnt work either.  Any guidance is MUCH appreciated - Im not sure where to go from here.

  • How do i get my computer to stop making a fan noise

    how do i get my computer to stop making a fan noise?

    Is the computer hot? If so then do this:
    Open Activity Monitor in the Utilities folder.  Select All Processes from the Processes dropdown menu.  Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    If the computer is not hot, then try resetting the SMC - Intel-based Macs: Resetting the System Management Controller (SMC).
    Finally, try running diagnostics:
    Using Apple Hardware Test
    OS X Mountain Lion- Use Apple Hardware Test
    Intel-based Macs- Using Apple Hardware Test
    MacBook Air- Using Apple Hardware Test

  • How do i get my computer to stop instantly recognizing my iphone???

    okay so my sister and i have two separate iphones and recently found out that her computer is recognizing it as the same one, so we are running out of storage space very quickly. how do i get my phone off of it or how do i get her computer to stop recognizing my phone as that account? please help

    Well that's the thing, it's not that... We set it up when I got my phone to sync with her account so I could get her music, but now I want my own because it's combining our space that's being used. I could tell because it says there are 1007 photos on that phone when that's our photos combined. I just want my own phone to recognize so it's not using up my storage.

  • How do I get my iPad to stop shutting down by itself?

    How do I get my iPad to stop shutting down by itself?

    What do you mean by "shutting down"?
    Have your Reset it? Restored it from your backup? Restored it as a new device?

  • How do I get my iPad to stop locking because of the Find my iPhone app?

    How do I get my iPad to stop locking because of the Find my iPhone app?

    The Find My iPhone app has nothing to do with this.
    Settings>General>Passcode lock
    Turn it off.

  • I tried to encrypt using file vault but it froze slowing my macbook pro, how can i get things moving or stop the encryption

    i tried to encrypt using file vault but it froze slowing my macbook pro, how can i get things moving or stop the encryption

    Back up all data before proceeding. There are ways to back up a computer that isn't fully functional. Ask if you need guidance.
    Start up in Recovery mode. When the OS X Utilities screen appears, select Disk Utility.
    In the Disk Utility window, select the icon of the startup volume from the list on the left. It will be nested below another disk icon, usually with the same name. Click the Unlock button in the toolbar. When prompted, enter the login password of a user authorized to unlock the volume, or the alternate decryption key that was generated when you activated FileVault.
    Then, from the menu bar, select
              File ▹ Turn Off Encryption
    Enter the password again.
    You can then restart as usual, if the system is working. Decryption will be completed in the background. It may take several hours, and during that time performance will be reduced.
    If you can't turn off encryption in Disk Utility because the menu item is grayed out, you'll have to erase the volume and then restore the data from a backup. Select the Erase tab, and then select
              Mac OS Extended (Journaled)
    from the Format menu.
    You can then quit to be returned to the main Recovery screen. Follow these instructions if you back up with Time Machine. If you use other backup software, follow its developer's instructions.
    Don't erase the volume unless you have at least two complete, independent backups. One is not enough to be safe.

  • HT5129 I keep getting the message MobileMe has been discontinued - iPhoto willmove albums you have published to MobileMe Gallery. . .  but I have not knowingly published any photos to MobileMe.  How can I get this message to stop.  It's getting annoying.

    I keep getting the message MobileMe has been discontinued - iPhoto willmove albums you have published to MobileMe Gallery. . .  but I have not knowingly published any photos to MobileMe.  How can I get this message to stop.  It's getting annoying.
    Also, how can I remove duplicate photos in an album without doing it manually?
    Thanks!

    When the prompt pops up next time you start iPhoto select Learn more. Then click on iPhoto preferences and select the Accounts tab. Delete your MM account and the quit iPhoto. Next time you open iPhoto the problem should be eliminated.

  • Outlook closes and will not download a particular message.How can i get that message to stop coming to my inbox?

    outlook closes and will not download a particular message.How can i get that message to stop coming to my inbox?

    Hi,
    May I ask your intention by doing this? Is the particular message harmful to your computer?
    Which type of email account are you using? If you want to prevent a particular message from being downloaded to Outlook, we can login to the web interface of your email account and then remove the particular email from your Inbox.
    If I've misunderstood something, please feel free to let me know.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • How do I get my apps to stop saying waiting

    How do I get my apps to stop saying waiting

    If there are multiple apps trying to download at once, only one can download at a time and the rest say "Waiting" until it is then their turn. Try this. Double tap the icon of the Waiting app, and it should resume the download.
    Another thing to try - Turn the iPad Off & then back ON.
    If that doesn't work:
    •  Log out of your iTunes store account.  Go to Settings > Store > Sign Out Then press the Home button.
    • Then press and hold the Home and Sleep buttons simultaneously and don't release them when it brings up the Turn Off screen; keep holding them until the Apple logo appears.
    • After restart, the Waiting should be gone.
     Cheers, Tom

Maybe you are looking for