🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
3 messages
3 total messages Started by Eric Tue, 23 Dec 2008 22:50
AS to JS translation questions
#2312
Author: Eric
Date: Tue, 23 Dec 2008 22:50
36 lines
1778 bytes
Hi all,

Still trying to convert the same script from AS to JS and I've bogged down again.

[1] I collect up a text range ala ID's print dialog (eg, 1-4, 5, 7) and then convert it into a list of document offsets (1, 2, 3, 4, 5, 7) that I can process in a loop. However, when I try and reference pages by those offsets, I am getting back different numbers. The key bits are:

for( j=startOffset; j <=endOffset; ++j ) { 
	offsetList = offsetList.concat( j ); 
} // Let's say offsetList becomes 1, 3 (ie, 2nd and 4th pages)

and then later:

for( thisOffset in offsetList ) { 
    var myPage = pages[ offsetList ] 
    alert( myPage.name ) 
} // Returns pages 1 and 2, not 2 and 4



[2] Secondly, a translation question. In Applescript, I can collect a list of every text frame with a certain script label by doing:

set oldFrames to every text frame whose label = "myMarker"

Is there a short-hand equivalent in JS or is something like this the only way:
for( thisFrame in textFrames ) {
    if( thisFrame.label == "myMarker" ) {
        oldFrames = oldFrames.concat( thisFrame )
    }
}

Gads, it is difficult thinking in JS after years of doing AS!

o_O

Thanks in advance,
Eric.
Re: AS to JS translation questions
#2313
Author: Peter Kahrel
Date: Wed, 24 Dec 2008 04:37
10 lines
757 bytes
Eric, 

      oldFrames = app.activeDocument.textFrames.item ('myMarker').getElements()




Creates an array of textframes whose label is "myMarker".

Peter
Re: AS to JS translation questions
#2314
Author: Eric
Date: Wed, 24 Dec 2008 17:52
3 lines
635 bytes
Again, thanks very much for the help.

Happy holidays!
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