🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
2 messages
2 total messages Started by Scott_Wood Fri, 20 Mar 2009 20:01
Need help to debug simple javascript in CS3
#450
Author: Scott_Wood
Date: Fri, 20 Mar 2009 20:01
18 lines
2308 bytes
Here's what I'm trying to accomplish:
I have 25 separate InDesign documents that have been populated via EasyCatalog and a data extract. There is one part of the content I need to target, which is a bullet list. The way the easy catalog brings in the bullets is via a table, each list is in it's own table, each bullet on it's own row (with a bullet character preceding the text in the row). Problem being that the client wants the bullets formatted like this (Bullet1 | Bullet2 | Bullet3) Basically a single line of copy that wraps in a text box, not a bullet list.

I need to convert each table in the document into text, then take out the bullet character and separate each row with the "|" character.

Here's the script that I finally got to run without errors, but now it just runs and runs and runs and doesn't do anything. It locks up indesign if I run it through the scripts panel, but running it through ExtentScript, I can stop it and continue using ID.
--------------------------------------------------------------------------

var myDoc = app.activeDocument;

for(i = myDoc.stories.length - 1; i >= 0; i)
for(j = myDoc.stories[i].tables.length - 1; j >= 0; j) { var myTable = myDoc.stories[i].tables[j]; myTable.convertToText( ",", "|"); }

--------------------------------------------------------------------------

I'm not very savvy with scripting, I've worked on this for many hours trying to figure it out. I'm hoping someone can just look at this and be like "you dumb@$$, just change xy & z and it'll work".

So anyone that'll consider looking at this, and see what I'm doing wrong, the help will be much appreciated. And you'd totally be free to heckle me for not being able to figure it out! :)
Re: Need help to debug simple javascript in CS3
#451
Author: Robert Tkaczyk
Date: Fri, 20 Mar 2009 21:26
25 lines
1340 bytes
you need to decrease "i" and "j"

"i--" and "j--"


for (var=startvalue;var<=endvalue;var=var+increment) 
{
    code to be executed
}

so:

--------------------------------------------------------------------------

var myDoc = app.activeDocument;

for(i = myDoc.stories.length - 1; i >= 0; i--)
for(j = myDoc.stories[i].tables.length - 1; j >= 0; j--) { var myTable = myDoc.stories[i].tables[j]; myTable.convertToText( ",", "|"); }

--------------------------------------------------------------------------

robin

-- 
www.adobescripts.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads