🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15624

JS: Copy/Paste

#15624
From: Dave_Saunders
Date: Wed, 26 Nov 2003 12:36
20 lines
1710 bytes
Recently, I needed to do some heavy duty shuffling of data in a table. I ended up using copy and paste in spite of warnings about how unreliable it can be. 50,000 copies and pastes later, I'm feeling pretty confident that on OS X they work mighty well. (I did them in 10.2.8, but I'm now using 10.3.1.) One thing about doing them in JavaScript is that you don't have to worry about activating the application because triggering the script activates the application.

So, this morning, faced with a client who can't decide which order he wants a table (increasing or decreasing), I decided to flex my new-found muscle and write a script to reverse the order of the rows in a table.

Here it is. It starts by assuming you have an insertion point active in some cell of the table:

//DESCRIPTION: Reverses the order of all rows in a table

myTable = app.selection[0].parent.parent;
myLim = myTable.rows.length;
if (myLim > 1) {
 for (n=myLim - 2; n > -1; n--) {
  myTable.rows[n].select();
  app.cut();
  myTable.rows[n].remove();
  myTable.rows.add(LocationOptions.atEnd);
  myTable.rows[-1].select();
  app.paste();
 }
}
Technical Details
Message-ID: <2cce9b87.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,a3cad43350bb7b3d,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-11-26 04:37:48 PST
From: Dave_Saunders@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: JS: Copy/Paste
Message-ID: <2cce9b87.-1@webx.la2eafNXanI>
Date: Wed, 26 Nov 2003 04:36:14 -0800
Lines: 29
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit