3 Replies Latest reply on Aug 6, 2015 1:15 PM by RobertKyle

    Is there a character limit for prompt()?

    RobertKyle Level 2

      I came across a comment on another website to the effect that the global method prompt() will crash PhotoShop if the user types more than 255 characters in the text field. From my brief experience today, I would say that the same limit applies to InCopy and InDesign as well. Has anyone else encountered this?

       

      I guess the next step would be to use ScriptUI to create a text-entry dialog.

        • 1. Re: Is there a character limit for prompt()?
          [Jongware] Most Valuable Participant

          I've never encountered such a limit ... but maybe it's because a prompt is for, well ... your basic prompting. Entering more than 200 characters is stretching its intended use The good news is a simple ScriptUI dialog can do the same thing, and you get a multi-line edit box for free. I cannot say anything on a maximum of text that can be entered into it, but I've pasted at least several thousands of characters into one.

          • 2. Re: Is there a character limit for prompt()?
            [Jongware] Most Valuable Participant

            ... here is a quick version of a Larger Prompt dialog. I just tested and could paste 29,721 characters into it. No idea where that limit comes from.

             

            text = largerPrompt ("Hello there!");
            alert ("you entered "+text.length+" characters");
            exit();
            
            function largerPrompt (title)
            {
                var w = new Window("dialog", title);
                var textfield = w.add ("edittext", [0, 0, 500, 300], "", {multiline: true});
                textfield.text = "Paste or type text in here\rUse Ctrl+Tab to insert a Tab, Ctrl+Enter to insert a Hard return";
                textfield.active = true;
                with (w.add("group"))
                {
                    orientation = "row";
                    add ("button", undefined, "OK");
                    add ("button", undefined, "Cancel");
                }
                if (w.show()==2)
                    return null;
            
                return textfield.text;
            }
            
            • 3. Re: Is there a character limit for prompt()?
              RobertKyle Level 2

              Thanks so much... I went ahead with the built-in prompt() and put the chore of creating a scriptUI version on my round-to-it list, but this just plugs and plays.