Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is there a character limit for prompt()?

Guest
Aug 05, 2015 Aug 05, 2015

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.

TOPICS
Scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 06, 2015 Aug 06, 2015

... 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

...
Translate
Community Expert ,
Aug 05, 2015 Aug 05, 2015

‌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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 06, 2015 Aug 06, 2015

... 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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 06, 2015 Aug 06, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines