Skip to main content
M.Hasanin
Inspiring
November 14, 2021
Answered

Text Frame Numbering Sequential is Slow and Poor Perfomance

  • November 14, 2021
  • 1 reply
  • 285 views

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

 

This topic has been closed for replies.
Correct answer m1b

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

1 reply

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
November 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

M.Hasanin
M.HasaninAuthor
Inspiring
November 15, 2021

@m1b 

Thanks too much indeed

Have a Great day 

Mohammad Hasanin