JSX prompt() limits user input to 255 characters.

New Here ,
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

54

Likes

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

Adobe Community Professional , 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...

Likes

Translate

Translate
Adobe Community Professional ,
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;
    })();
}

Likes

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
New Here ,
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.

Likes

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