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

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
Mohammad Hasanin
TOPICS
Scripting

Views

135

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

Votes

Translate

Translate
Community Expert ,
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

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

Copy link to clipboard

Copied

LATEST

@m1b 

Thanks too much indeed

Have a Great day 

Best
Mohammad Hasanin

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