Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Dialog EditText field collect array?

Participant ,
Dec 20, 2020 Dec 20, 2020

Copy link to clipboard

Copied

I want to have a field in my dialog box that will collect and array of numbers seperated by comma. Would I need to collect that as a string or can i go strait to an array? If not how would I convert that string?

 

var dialog = new Window("dialog"); 
    dialog.text = "SETUP"; 
    dialog.orientation = "row"; 
    dialog.alignChildren = ["left","top"]; 
    dialog.spacing = 10; 
    dialog.margins = 16; 

// GROUP1
// ======
var group1 = dialog.add("group", undefined, {name: "group1"}); 
    group1.preferredSize.width = 343; 
    group1.orientation = "column"; 
    group1.alignChildren = ["left","center"]; 
    group1.spacing = 9; 
    group1.margins = 0;

var edittext1 = group1.add('edittext {properties: {name: "edittext1"}}'); 
    edittext1.text = "Page numbers ie. 1,5,9"; 
    edittext1.preferredSize.width = 368; 
    edittext1.preferredSize.height = 30; 

var result = dialog.show();
----------
var pagesVar = (edittext1.text);
var pageNumbers = pagesVar.match(/\d+/g); //Tried this doesn't seem to work

$.writeln(edittext1.text);
$.writeln(pageNumbers.length-1);//tested to see if I could get the last number, didn't give the correct one

 

TOPICS
Scripting

Views

134

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

Participant , Dec 20, 2020 Dec 20, 2020
I got it.  var pagesVar = (edittext1.text); var pageNumbers = eval('['+pagesVar+']');

Likes

Translate

Translate
Participant ,
Dec 20, 2020 Dec 20, 2020

Copy link to clipboard

Copied

I got it. 

 

var pagesVar = (edittext1.text);
var pageNumbers = eval('['+pagesVar+']');

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
Adobe Community Professional ,
Dec 20, 2020 Dec 20, 2020

Copy link to clipboard

Copied

Alternatively, assuming comma-separated entries in the text field: 

var pageNumbers = edittext1.text.split(",");

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
Participant ,
Dec 21, 2020 Dec 21, 2020

Copy link to clipboard

Copied

I tried this but couldn't get it to work, I had just assumed it wasn't available in extendscript.

 

 

var lastPage = pageNumbers[pageNumbers.length-1];
myDoc.documentPreferences.pagesPerDocument = lastPage;

 

 

The error I get is Expected Long Integer, but received "16". I'm assuming by the quotes that it is still a string. 

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
Adobe Community Professional ,
Dec 21, 2020 Dec 21, 2020

Copy link to clipboard

Copied

LATEST

Correct. You can use parseInt to convert it: 

myDoc.documentPreferences.pagesPerDocument = parseInt(lastPage);

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