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.


Text Frame Numbering Sequential is Slow and Poor Perfomance

Enthusiast ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

Hi Experts, Please I need your help to increase performance to this simple scirpt, the script shouid insert 5000 number in everyline in user selected text frame but the performance is very slow and poor!, do i need to change the way of the loop? , i tried many loops methods and all of them are Slow and Poor Performance.

 

start = 1;
end = 5000;
var mySel = app.selection[0].parentStory
for (var i = start; i <= end; i++) {
    mySel.contents  += (i + "\r"); 
}

 

Please Help if you can with tips to increase the Performance!.

Thanks in Advance

 

Best
M.Hasanain
TOPICS
Scripting

Views

52

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

Enthusiast , Nov 14, 2021 Nov 14, 2021
Try something like this:var start = 1, end = 5000, mySel = app.selection[0].parentStory, myNums = []; for (var i = start; i <= end; i++) { myNums.push(i); } mySel.contents = myNums.join('\n'); I've generated the numbers as an array of Numbers and only at the last step put them into Indesign. Should be much quicker!- Mark

Likes

Translate

Translate
Enthusiast ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

Try something like this:

var start = 1,
    end = 5000,
    mySel = app.selection[0].parentStory,
    myNums = [];
for (var i = start; i <= end; i++) {
    myNums.push(i);
}
mySel.contents = myNums.join('\n');

 

I've generated the numbers as an array of Numbers and only at the last step put them into Indesign. Should be much quicker!

- Mark

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
Enthusiast ,
Nov 14, 2021 Nov 14, 2021

Copy link to clipboard

Copied

LATEST

@m1b 

Thanks too much indeed

Have a Great day 

Best
M.Hasanain

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