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

JSX prompt() limits user input to 255 characters.

Community Beginner ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

When I enter more than 255 characters in a prompt(), the returning value gets cut off at character 255.  

 

Illustrator 25.4.1

WIN 11 64-bit

 

I run the script by clicking File > Scripts > Other Script... and then navigating to the script.  When prompted I just copy the value initially assigned to the variable, paste and click OK.

 

Script:

var pastedValues = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
alert(pastedValues + "has a length of " + pastedValues.length);

pastedValues = prompt("Paste values", "");
alert(pastedValues + "has a length of " + pastedValues.length);

Thanks. 

TOPICS
Scripting

Views

237

Translate

Translate

Report

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 , May 04, 2022 May 04, 2022

Hi @m1cmdrpitch, here is a function I wrote that could replace the built-in prompt(). It uses adobe's implementation of scriptUI to handle the UI.

- Mark

 

var pastedValues = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
alert(pastedValues + "has a leng
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

Hi @m1cmdrpitch, here is a function I wrote that could replace the built-in prompt(). It uses adobe's implementation of scriptUI to handle the UI.

- Mark

 

var pastedValues = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
alert(pastedValues + "has a length of " + pastedValues.length);

pastedValues = prompter(pastedValues, 'Prompter test', 'Paste string here:');
if (pastedValues != undefined)
    alert(pastedValues + "has a length of " + pastedValues.length);


function prompter(obj, title, message) {
    title = title || '';
    return (function () {
        var result;
        if (obj instanceof Array) { obj = obj.join('\r') };
        var w = new Window('dialog', title);
        if (message != undefined)
            w.add('statictext', undefined, message, { alignment: 'left' });
        var textArea = w.add('edittext', undefined, obj, { multiline: true, scrolling: true });
        textArea.maximumSize.height = w.maximumSize.height - 100;
        textArea.minimumSize.height = 150;
        textArea.minimumSize.width = 500;
        var button = w.add('button', undefined, 'Done', { name: 'ok' });
        button.onClick = function (ev) {
            result = textArea.text;
            w.close(1);
        };
        if (w.show() == 1) return result;
    })();
}

Votes

Translate

Translate

Report

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 Beginner ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

LATEST

That prompter function looks and works great, scrollable and multi-lined are nice UX upgrades.

 

Just for documentation purposes here is what that function produces:

 

Prompter.png

 

 

 

 

 

 

 

 

 

Thanks.

Votes

Translate

Translate

Report

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