Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions If propmt = example, redo prompt?

  • If propmt = example, redo prompt?

    Posted by Jacob Danell on May 7, 2014 at 9:07 pm

    Hi! In my script I’m trying to make I will have a prompt, asking the user to change the name but if the name isn’t changed/ending up the same I want a warning to come up and the user have to redo the prompt.
    Can’t figure out how to do this without making maaany if-statements after each other.

    Jacob Danell replied 12 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 7, 2014 at 11:53 pm

    Hard to say exactly what fits your situation, but maybe something like this:


    // initialization
    var oldName = "whatever";

    // prompt user for new name
    var newName = oldName;
    var myPrompt = "Enter new name.";
    while (newName == oldName){
    newName = prompt(myPrompt,"");
    if (newName == null) break;
    myPrompt = "Name already in use. Enter new name."
    }

    if (newName == null){
    alert("User canceled.");
    }else{
    oldName = newName; // ready for next time
    alert(newName);
    }

    Dan

  • Jacob Danell

    May 8, 2014 at 3:47 pm

    While!! How could I forget while! The code worked perfectly! Thanks!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy