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

With CS2, some things have changed

Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

I have not located a place where changes in scripting between CS and CS2 are reported, so I thought I'd start a topic here with some of the things I know about.

This is about changes to the object model that are not related to changes in the functionality that have taken place.


1. User Interaction Control
2. Table Labels
3. Parent Text Frame
4. New Beep Function
5. Find/Change symbol for End Nested Style Here
6. Convert to Table
7. Active Script in doScript
8. Text selections more specific

9. Table selections
10. Indexes
11. Basic Paragraph style
12. Enumeration Name Changes
13. Placed Assets
14. Previous Text Frame
15. Version Property
16. Add Page Reference (Index)


In describing these in the following messages, I'll use JavaScript terminology, but most of these issues are independent of the language.
TOPICS
Scripting

Views

15.6K

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

User Interaction Control

In CS, one would write:

app.userInteractionLevel = UserInteractionLevels.neverInteract;
app.userInteractionLevel = UserInteractionLevels.interactWithAll;

In CS2, because of the new scriptPreferences property, one must use:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

There is a third preference option now:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAlerts;

The intention of this mode of operating is that any dialogs would be suppressed with the default settings accepted, but any alerts that your scripting actions caused would still be displayed. I have yet to successfully use this option.

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Table Labels

This is more a change in functionality of the product, but if (like me) you had used labels for tables in CS confident that the user wouldn't see them, this is changed in CS2. If you select a whole table in the UI, you'll see the Script Label (if there is one) in the Script Label palette.

Note also that cells can now have labels. This should help those people who want to automate linkages between parts of tables with parts of spreadsheets. Cell labels too are visible in the UI.

In the situation where a table consists of just one cell (I use these in my HeadStraddler product), you can see only the table label in the UI. To see the cell label, you'd have to temporarily add a cell to the table.

The really good news here is that both Cells and Tables have the insertLabel and extractLabel methods, so you can still have labels added by your scripts that aren't visible in the UI.

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Parent Text Frames

This change is likely to cause a fair amount of editing. In CS, the text property parentTextFrame sometimes returned a collection making its name rather confusing. Now, it always returns a collection and so its name has been changed to the plural form.

So, if the only thing you care about is the parent text frame of the first character of some text, you can write:

myTF = myText.parentTextFrames[0];

If you want to know if some text spans more than one frame, use:

if (myText.parentTextFrames.length > 1) ...

If you want to know if some text is wholly overset, use:

if (myText.parentTextFrames.length == 0) ...

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

New Beep Function

I think this is JS only. Whereas before, exit() issued a beep as it exited, it now exits silently. However, there is a new beep() method to create a beep. This means you can issue a beep as you pop-up an alert.

I've been using this function to manage my exiting from scripts so that they will work with either CS or CS2:

function errorExit(message) {
if (app.version != 3) { beep() } // CS2 includes beep() function.
if (arguments.length > 0) {
alert(message);
}
exit(); // CS exits with a beep; CS2 exits silently.
}

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Find/Change End Nested Style

This is more of a functional change of the application itself. The symbol used by Find/Change for End Nested Style Here is now ^h rather than ^\. I don't think I ever actually used that symbol in a script but had I done so ...

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Convert to Table

I've been grappling with this one most of the day. There is something strange associated with the form of the convert to table method when used with three parameters (as you do when you want the return character to delimit both cells and rows).

In CS, my HeadStraddler product uses:

myTable = myText.convertToTable("\r","\r",1);

to convert the text of the first paragraph of a text frame (less its paragraph marker) to a single-cell table. To get this to work properly in CS2, I have had to use:

myTable = myText.convertToTable("\r","\r",1)[0];

but this has the look of an unintentional bug, so I'm actually restructuring what I'm doing altogether, taking advantage of the fact that the table is the first thing in the frame, so I've changed the original to:

myText.convertToTable("\r","\r",1);
myTable = myFrame.characters[0].tables[0];

I did this to protect against the bug being fixed and my script needing to be changed again.

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Active Script in a doScript

In CS, if you did this:

myTest = "alert(app.activeScript)"
app.doScript(myTest);

You would see an alert that gives you the path to the base script.

In CS2, doScript is handled differently. The attempt to run the script in myTest results in an error message that the script doesn't have an associated script file.

This is true even if you use the new versioning feature:

if (app.version != 3) {app.scriptPreferences.version = 3.0}
myTest = "alert(app.activeScript)"
app.doScript(myTest);

will still give you the error because of the fundamentally different manner in which scripts are run with CS2.

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
Participant ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

This list is by no means exhaustive, but these are the things I've run into in the past few days.

If any of you know of any other topics worthy of adding to this list, please e-mail me (my address is accessible if you click my name) or start another topic and I'll add them in here with the links at top.

If you want to discuss or explore any of the topics I've posted, feel free to start a new topic.

Dave

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
Explorer ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Hi Dave--

Regarding your doScript example--you haven't given it a file to run, you've given it a string. I'm not sure what you mean by "the fundamentally different manner in which scripts are run with CS2"--I don't see it. If doScript for a string returned a file for a string being run using doScript in CS, then it was an error.

In addition, if you use doScript to run a script file, then app.activeScript should return the name of that file, not the name of the script in which the doScript statement is used.

Thanks,

Ole

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
Explorer ,
Apr 25, 2005 Apr 25, 2005

Copy link to clipboard

Copied

Hi Dave--

Regarding the end nested style metacharacter--this is also true in the user interface, so it's not only a scripting change (and, for that matter, we have no control over it). While I disagree with the UI team changing find/change metacharacters without notice, I do check the metacharacters list with each new release, just in case.

Thanks,

Ole

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
Participant ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

re: doScript

In CS, that script I posted in number 7 returns the path of the script that called the doScript in CS2 it doesn't. That's the difference I'm pointing out.

The reason is that CS2 runs each script in a separate domain (if you use ESTK to debug a script that uses doScript you'll quickly see what I mean).

This change breaks some of my scripts rather badly. Fortunately, as you pointed out elsewhere, I can use scriptArgs to pass this information around.

Dave

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
Participant ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

Text Selections

Text selections are more specific about what is selected than in CS. While CS would only ever give you Text or InsertionPoint as the kind of selection, CS2 will give you responses like Word or Paragraph.

In JavaScript, I use this method to determine if an object is text:
Object.prototype.isText = function() {

switch(this.constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "TextFrame":
return true;
default :
return false;
}
}

So, I can write:

if (app.selection[0].isText()) {
// if we get here, the selection is text

etc.

Notice that I include TextFrame as text. Perhaps a second method called isStrictlyText() would exclude text frames.

Dave

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
Community Beginner ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

In ID 2.0.2 - was't the same ??

robin

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
Participant ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

Table Selection

If you have a whole table selected, then the type of the selection is returned as Table rather than a collection of Cells as before.

Note that if you have a table with header and/or footer rows, selecting all the regular cells is not the same as selecting the whole table.

If you have a row or a column selected, these are still returned as a collection of cells.

Dave

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
Community Beginner ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

Hi,
In CS the Unicode "\u0016"= Table.
Has been changed in CS2?

Thanks.

jxswm

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
Participant ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

I don't know -- but I'd advise against using unicode values to identify tables. Doing that kind of thing falls into the category of reverse engineering, it seems to me, and is not something that can necessarily be relied upon from one release to the next.

Dave

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
Participant ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

Maybe, but I'd regard it as an implementation detail and not something to be relied upon. It's safe to rely on it for a particular release, but if they choose to implement tables in an entirely different way, they're free to do so, it seems to me. That a table has a unicode is not documented -- it's something we scripters found out by digging.

Doesn't mean that it will change; just that it might.

Dave

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
New Here ,
Apr 26, 2005 Apr 26, 2005

Copy link to clipboard

Copied

> don't know -- but I'd advise against using unicode values to identify tables. Doing that kind of thing falls into the category of reverse engineering, it seems to me, and is not something that can necessarily be relied upon from one release to the next.

Very true. Relying on undocumented features is a good way to have your scripts break with the next release.

However, since Adobe has no compunction about breaking documented behavior with a new release, it doesn't make much difference, does it?

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
Community Expert ,
Apr 27, 2005 Apr 27, 2005

Copy link to clipboard

Copied

Indexes

Scripting indexes has changed a lot. It finally works, and it works well. The property 'subtopic' has gone, instead you iterate the property 'topic' (up to three times). The following lines illustrate:

if( app.activeDocument.indexes.length == 0 )
myIndex = app.activeDocument.indexes.add()
else
myIndex = app.activeDocument.indexes[0]

//create main topic
myIndex.topics.add('dog')
//create subtopics
myIndex.topics.item('dog').topics.add('collie')
myIndex.topics.item('dog').topics.add('setter')
myIndex.topics.item('dog').topics.item('collie').topics.add('border collie')
myIndex.topics.item('dog').topics.item('collie').topics.item('border collie').topics.add('bitch')

You can address (sub)topics by asking for topics embedded under topics:

myIndex.topics[0].topics[0].topics[0].topics[0].name

is the first subtopic of the first subtopic of the first subtopic of the first topic.

A new property is allTopics: myIndex.allTopics returns an array of all (sub)topics. This is a flat, one-dimensional, array, i.e. it returns the whole index but without structure.

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
Explorer ,
Apr 27, 2005 Apr 27, 2005

Copy link to clipboard

Copied

Peter--

Glad you noticed that we fixed indexing! I'd actually somewhat forgotten about it, as it's not a new feature--we just made it work the way it was always supposed to work. (It was originally implemented by WinSoft in France--between their English and my French, some things were lost in translation.)

There's still a lot to do, and there are still some bugs to fix--I'd urge you not to change the sort order for an existing index topic using scripting, as it's pretty fragile. But it's much better--for scripting and for saving to .inx.

I like adding the "flattened" collections--such as allTopics--wherever we can (to avoid having to use iteration/recursion to find things), so it made sense to take care of it while we were working on the plug-in.

Thanks,

Ole

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
New Here ,
Apr 27, 2005 Apr 27, 2005

Copy link to clipboard

Copied

Hey, wait - "sort order" ?<br /><br />Does it do what one would think it does? I.e. change sort order to that of<br />different alphabets such as German, English, Norwegian etc?<br /><br />Where is that located in the UI? I can't find it<br /><br /><br /><br />On 05-04-28 02.58, in article 3bba0c2a.19@webx.la2eafNXanI,<br />"Olav_Kvern@adobeforums.com" <Olav_Kvern@adobeforums.com> wrote:<br /><br />> There's still a lot to do, and there are still some bugs to fix--I'd urge you<br />> not to change the sort order for an existing index topic using scripting, as<br />> it's pretty fragile. But it's much better--for scripting and for saving to<br />> .inx.

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
Community Beginner ,
Apr 27, 2005 Apr 27, 2005

Copy link to clipboard

Copied

//----------------------------------------
A new property is allTopics: myIndex.allTopics returns an array of all (sub)topics. This is a flat, one-dimensional, array, i.e. it returns the whole index but without structure.
//----------------------------------------
In CS:
allTopics = myIndex.topics.everyItem().subtopics.everyItem();

But if change the topics's one subTopic's sortOrder, the subTopic's index has been changed, it means:
the before subTopic != after subTopic;
I have spent so much time to solve the problem.
Is not the same as the in CS2?

jxswm

jxswm

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
Community Expert ,
Apr 28, 2005 Apr 28, 2005

Copy link to clipboard

Copied

Richard,

Sort order is here the 'Sort By' panel in the Topic Options dialog, used to set the sort order of individual entries. Sort order for particular languages is still sadly missing.

jxswm,

I don't know if it's fixed in CS2, but as Ole mentioned that it's still fragile in CS2, you'd better hang on to your solution.

Peter

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
Community Beginner ,
Apr 28, 2005 Apr 28, 2005

Copy link to clipboard

Copied

Yes!

The problems in index CJK language Sorting:

b Common problems:
<1>. Simple Chinese(Chs): Phonetic--Stroke sorting can be not identifed automately;
<2>. Traditional Chinese(BIG5): Stroke sorting can be not identifed automately;
<3>. Korean can not be sorting by KS Code automately;

So: I using IndexSort Plug-In or Script to sort by:
(1). Chines Simplified(GBK) Phonetic;
(2). Chines Simplified(GBK) Stroke;
(3). Chines Traditional(BIG5) Stroke;
(4). Hangul(Korea)(KS Code);
(5). ACII

In '(5). ACII' Can change sort order to that of
different alphabets such as German, English, Norwegian etc?

//-----------------------------------------------
My meaning is: In CS2 is there a way to sort the order autoly, because I must to run the Plug-In or Script by hand now.

Thanks.

jxwswm

> http://websamba.com/IDscript/



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