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

Code to be evaluated! [005]

LEGEND ,
Nov 03, 2016 Nov 03, 2016

Copy link to clipboard

Copied

Hi Scripters!

This script seems to work fine but I'm not truly convinced by its code [ I've written, I agree!  ]

Object:  find all paras with a "word spacing more than 100% desired" and apply them "a word spacing 95% desired"!

  1. var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements(); 
  2. var mydesiredWordSpacing_0 = 100
  3. var mydesiredWordSpacing_1 = 95
  4. for (p = 0; p < myParas.length; p++) 
  5.     { 
  6.         var mydesiredWordSpacing = myParas

    .desiredWordSpacing; 

  7.         if (mydesiredWordSpacing > mydesiredWordSpacing_0) { 
  8.             mydesiredWordSpacing = mydesiredWordSpacing_1; 
  9.             myParas

    .desiredWordSpacing = mydesiredWordSpacing; 

  10.         } 
  11.     }

(^/)

TOPICS
Scripting

Views

286

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 , Nov 04, 2016 Nov 04, 2016

From what I understood of your code:

Array.prototype.resetSpacing = function() {

  var item;

  while ( item = this.pop() ) item.desiredWordSpacing>100 && item.desiredWordSpacing=95;

}

app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements().resetSpacing();

Votes

Translate

Translate
Participant ,
Nov 04, 2016 Nov 04, 2016

Copy link to clipboard

Copied

From what I understood of your code:

Array.prototype.resetSpacing = function() {

  var item;

  while ( item = this.pop() ) item.desiredWordSpacing>100 && item.desiredWordSpacing=95;

}

app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements().resetSpacing();

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
LEGEND ,
Nov 04, 2016 Nov 04, 2016

Copy link to clipboard

Copied

LATEST

Wow!  Loic, very nice code! 

After his study [2 hours!], I can even say I understand it!

Thank you very much!

(^/)

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